Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling code that is located in another form. 1

Status
Not open for further replies.

eon5

Technical User
Dec 31, 2007
47
ZA
Good Day,

In my current form “ComponentInformation” I have a procedure called “Refresh” when I click the refresh button on the form it works perfectly.

In my second form “VendorInformation” I would like to call the “Refresh” procedure after updating the VendorID.

How do I call code that is in another form?

The following code does not work because it is looking for the code in the “VendorInformation” Form, but instead the code is in the “ComponentInformation” Form.

Private Sub VendorID_AfterUpdate()
Call Refresh_Click
End Sub

Regards
Theuns
 
Code:
Forms!ComponentInformation.Refresh

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Thanks for the help.

The code that you provided me with works perfectly and was exactly what i needed, but still for interest sake how doe one call a procedure form another form, or is it a stupid question?

Regards
Theuns
 
Suppose you have a PUBLIC sub in frmFirst
Code:
[b]Public[/b] Sub ShowMessage()
    MsgBox ("Hello From frmFirst")
End Sub
Then you call it from frmSecond like this way
Code:
Private Sub Command1_Click()
    Forms!frmFirst.ShowMessage
End Sub

frmFirst Should be loaded/open to call it otherwise it will throw an error.

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Ah... If you can set your Public subs in a module then you can call them any time.

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Cool, Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top