如何配置按钮来运行vba中的方法
我有一个正在用 vba 开发的自定义应用程序。我已经编写了所有代码,唯一令我困惑的是如何配置按钮来实际“启动”或“运行”程序。在用户端的表单上,用户将输入一个项目编号,然后按下一个按钮,在一个新的小表单上弹出一堆字段和文本框供用户输入,该窗口显示默认值和将更新/保存新的或更新的字段并将其插入数据库。
该按钮是在 microsoft-gp 中设计的,但我必须手动对其进行编码才能运行该程序。
现在,当我单击该按钮时,会弹出窗口,但文本框中没有显示任何信息,也没有显示组合框值。
这是我的程序的开始。
Private rs As Recordset
Public Sub Main()
DisplayWindow
'Item Number is the primary field for pulling data
ScanTable ItemMaintenance.ItemNumber
Cleanup
End Sub
Private Sub DisplayWindow()
'show vendor information screen
frmItemProfile.txtItemNumber = ItemMaintenance.ItemNumber
'build combobox with values
Build_Class_Group_ComboBox
'Show the form
frmItemProfile.Show
End Sub
当我在 vba 中运行这两种方法时,信息显示在表单上并且工作 100% 现在我必须在原始表单上对按钮进行编码,这就是我所拥有的; Test = 按钮名称
Private Sub Test_Changed()
frmItemProfile.Show
End Sub
如何对按钮进行编码以正确运行程序?如果有人能够阐明这个问题,我将不胜感激!提前致谢!
I have a custom application I am developing in vba. I have written all the code and the only thing I am confused about is how to configure a button to actually "start" or "run" the program. On the form on the user side, the user will type in an item number, then a button will be pushed that brings up a bunch of fields and textboxes on a new small form for the user to enter, The window displays the default values and will update/save new or updated fields and insert it into the database.
The button is designed in microsoft-gp but I have to manually code it to run the program.
Right now, when I click the button, the window pops up, but no information is displayed in the textboxes nor are the combobox values being displayed.
Here is the beginning of my program.
Private rs As Recordset
Public Sub Main()
DisplayWindow
'Item Number is the primary field for pulling data
ScanTable ItemMaintenance.ItemNumber
Cleanup
End Sub
Private Sub DisplayWindow()
'show vendor information screen
frmItemProfile.txtItemNumber = ItemMaintenance.ItemNumber
'build combobox with values
Build_Class_Group_ComboBox
'Show the form
frmItemProfile.Show
End Sub
When I run these two methods in vba, the information displays on the form and works 100%
Now I have to code the button on the original form so this is what I have ; Test = name of the button
Private Sub Test_Changed()
frmItemProfile.Show
End Sub
How can I code the button to run the program properly? If anyone could shed some light on the issue I would greatly appreciate it! Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设你已经尝试过:
I assume you've tried: