ms-access - 如何在访问中将文本框的多个值从一个表单传递到另一个表单
问题描述
我的库存数据库中有两种购买和销售表格。有时我需要直接在购买表格中显示购买出售。我已经看到其他类似的问题无法解决我的问题。我也试过如下:
Option Compare Database
Private Sub Command25_Click()
MsgBox "Are you sure to show this purchase as direct sale?", vbYesNo, "Direct Sale"
If vbYes Then
DoCmd.OpenForm "SF02PurchasetoSale", acNormal, , , , , DirectSale
End If
End Sub
Private Sub DirectSale()
Forms![SF02PurchasetoSale].[TxnDate] = Me.TxnDate.Value
Forms![SF02PurchasetoSale].[Hub] = Me.Hub.Value
Forms![SF02PurchasetoSale].[Code] = Me.Code.Value
Forms![SF02PurchasetoSale].[PurchasePrice] = Me.PurchasePrice.Value
Forms![SF02PurchasetoSale].[QtySold] = Me.QuantityPurchased.Value
End Sub
这显示了 DirectSale 的 openargs 上的“编译错误:预期的函数或变量”。我真的需要一些帮助。谢谢...
解决方案
OpenArgs 是将值传递给 OpenForm 或 OpenReport 命令中指定的表单或报表。考虑:
DoCmd.OpenForm "SF02PurchasetoSale", acNormal, , , acFormAdd, , "DirectSale"
然后在 SF02PurchasetoSale 后面编写代码:
Private Sub Form_Load()
With Me
If .OpenArgs = "DirectSale" Then
.[TxnDate] = Forms!Purchases.TxnDate
.[Hub] = Forms!Purchases.Hub
.[Code] = Forms!Purchases.Code
.[PurchasePrice] = Forms!Purchases.PurchasePrice
.[QtySold] = Forms!Purchases.QuantityPurchased
End If
End With
End Sub
推荐阅读
- python - 在 Python 中拟合来自多个对象的 2D 散点图数据
- deep-learning - 使用 CNN+HMM 模型为语音转文本项目标记 detaset
- stripe-payments - Stripe 监听和转发多个 webhook
- python - “errorMessage”:“模块‘lambda_function’上缺少处理程序‘lambda_handler’”
- javascript - 替换 WordPress 小部件内容类
- javascript - 为什么在IDE中使用动态变量名会出错,但codeandbox工作正常?
- reactjs - 过滤街景用户生成的图像
- imgur - 为什么 Imgur 说 Upload failed, remote server returned an error: File is over the size limit (using Obsidian Plugin)
- android-studio - 我正在尝试在 android studio 上运行我的模拟器,但我不断收到这个 adb 错误
- swift - AppKit/CoreServices KeyCode 和键盘映射(无 NSEvent)