如何配置按钮来运行vba中的方法

发布于 2025-01-03 04:13:19 字数 956 浏览 1 评论 0原文

我有一个正在用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泼猴你往哪里跑 2025-01-10 04:13:19

我假设你已经尝试过:

Private Sub Test_Click()
    Main()
End Sub

I assume you've tried:

Private Sub Test_Click()
    Main()
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文