我想在事件过程中设置新记录表单字段的值 [英] I want to set a value of a a new record form field in event procedure

查看:44
本文介绍了我想在事件过程中设置新记录表单字段的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个命令按钮打开一个表单的新记录,该表单的其中一个字段具有另一个表单的组合框的值.

I want a command button to open a new record of a form with one of its fields to have a value of a combo box from another form.

库存是表单名称,而PRODUCT_CODE是表单中的字段名称 Combo_Product_number是另一种形式的组合框名称.

Inventory is the form name while PRODUCT_CODE is a field name in the form Combo_Product_number is a combobox name of another form.

因此,我希望表单以product_code值字段打开,并且已用组合框的值填充.

So I want the form to openwith a product_code value field to have been filled with the value of the combobox.

而其余字段为空.

我很新来访问

Private Sub Command5_Click()

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FRM_Inventory_A03"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    DoCmd.GoToRecord , , acNewRec
    Forms!FRM_Inventory_A03!PRODUCT_CODE='& Me!Combo_Product_number & "'"

End Sub

推荐答案

我组成了2种形式.在frm1中有一个名为Combo_Product_number的组合框.

I made up 2 forms. In frm1 there is a combobox named Combo_Product_number.

还有一个名为FRM_Inventory_A03的表格.

frm1中,有一个带数字的组合框和一个名为Command5的按钮.单击后,按钮将在 FRM_Inventory_A03表单. > acFormAdd模式

In frm1 there is a combobox with numbers, and a button named Command5. When clicked, the button will open the form FRM_Inventory_A03 in acFormAdd mode

FRM_Inventory_A03中有3个字段,但其中一个名为PRODUCT_CODE

In FRM_Inventory_A03 there are 3 fields, but one of them is named PRODUCT_CODE

该按钮的代码为:

Private Sub Command5_Click()
DoCmd.OpenForm "FRM_Inventory_A03", acNormal, , , acFormAdd, acDialog
End Sub

现在,当您打开窗体FRM_Inventory_A03​​以添加新记录时,您想要分配组合框Combo_Product_number的值来控制PRODUCT_CODE.

Now, when you open the form FRM_Inventory_A03 to add a new record, you want to assign the value of the combobox Combo_Product_number to control PRODUCT_CODE.

为此,您需要在设计方式下打开表单FRM_Inventory_A03,选择控件PRODUCT_CODE,然后在属性的数据"选项卡中的属性DefaultValue中键入以下内容:

To do this, you need to open the form FRM_Inventory_A03 in Design Mode, select control PRODUCT_CODE and in the properties, data tab, in property DefaultValue, type this:

=[Forms]![frm1]![Combo_Product_number]

这会将组合框Combo_Product_number的值传递给控制PRODUCT_CODE.

This will pass the value of the combobox Combo_Product_number to control PRODUCT_CODE.

希望您可以使其适应您的需求.

Hope you can adapt this to your needs.

这篇关于我想在事件过程中设置新记录表单字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆