0

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!

javasocute
  • 648
  • 2
  • 11
  • 28

1 Answers1

0

I assume you've tried:

Private Sub Test_Click()
    Main()
End Sub
pete
  • 24,141
  • 4
  • 37
  • 51
  • My problem isnt the window coming up, the window appears when the button is clicked; but the issue is the fields are not being filled with the default data. – javasocute Feb 07 '12 at 20:03
  • Ok, so call your `Main` method in the button click handler. Answer updated. – pete Feb 07 '12 at 20:15