如何为绑定文本框设置值 [英] How to set value for bound text box

查看:90
本文介绍了如何为绑定文本框设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何在VBA中设置绑定文本框列的值 - 访问应用程序项目。



的例子 - 我创建了两个表单名称,如[mainFrm,subFrm],两个表单都有学生详细信息。我在文本框中绑定了学生ID。首先我默认执行mainFrm将显示​​第一条记录。然后通过导航下一个/上一个选择一些其他学生记录。然后我触发一个命令按钮事件来调用subFrm,这里我需要将id值设置为mainFrm中的subFrm。





 私有  Sub  OpensubFrm_Button_Click()


DoCmd.OpenForm subFrm,acNormal ,, [Stud_ID] =& Forms!mainFrm!Stud_ID

Forms!subFrm!Stud_ID = Forms!mainFrm!Stud_ID

End Sub





我收到错误,你无法为这个对象赋值< br $> b $ b

帮帮我吧!



预付结转





问候,

Prakash.T

解决方案

你真的在mainform上有子表单吗?我看到你试图将现有表单作为一个单独的窗口打开。在这种情况下,您不能以这种方式绑定数据。您需要动态更改 subfrm 的查询/来源,或者编写引用 mainfrm 的查询,类似这样的:

  SELECT  * 
FROM SecondTable
WHERE Stud_Id = Forms!MainFrm!Stud_ID





请按照以下链接:

运行参数查询 [ ^ ]

http:// www.btabdevelopment.com/ts/frmrefinqry [ ^ ]

http://www.meadinkent.co .uk / accformparams.htm [ ^ ]

当前事件[OnCurrent Property] [ ^ ]

创建子表单 [ ^ ]


Hi,

how to set value for bound text box column in VBA - access application project.

for an example - I have created 2 forms name like [mainFrm, subFrm], both forms having student details. I bound Student ID in text box. First I execute mainFrm by default first record will be shown. then selects some other record of student by navigating next/previous. and then I fire a command button event to call subFrm and here i need set id value to the subFrm which was in the mainFrm.


Private Sub OpensubFrm_Button_Click()


        DoCmd.OpenForm "subFrm", acNormal, , "[Stud_ID] = " & Forms!mainFrm!Stud_ID

        Forms!subFrm!Stud_ID = Forms!mainFrm!Stud_ID

End Sub



I am getting error, "you cannot assign value to this object"

Help me!

Thanks in Advance


Regards,
Prakash.T

解决方案

Do you really have subform on mainform? I see that you''re trying to open existing form as a separate window. In this case you can''t bind data in this way. You need to dynamically change query / source of your subfrm or to write query which refer to mainfrm, something like this one:

SELECT *
FROM SecondTable
WHERE Stud_Id = Forms!MainFrm!Stud_ID



Please, follow these links:
Run a parameter query[^]
http://www.btabdevelopment.com/ts/frmrefinqry[^]
http://www.meadinkent.co.uk/accformparams.htm[^]
Current event [OnCurrent Property][^]
Create a subform[^]


这篇关于如何为绑定文本框设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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