如何在访问中将文本框的多个值从一种形式传递到另一种形式

时间:2020-10-24 15:21:01

标签: 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上显示“编译错误:预期函数或变量”。我真的需要一些帮助。谢谢...

1 个答案:

答案 0 :(得分:0)

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
相关问题