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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign module to a button 2

Status
Not open for further replies.

digitalpencil

Programmer
Apr 8, 2001
165
GB
Hi, have just finished writing a module and would now like to assign it to a command button on a form.
How is this achieved?

I've gone through the properties and found the onClick but you seem to only be able to either pick a macro or write a new event procedure.. there must be a way of picking a pre-existing one.

Thanks
 
Create a new event procedure behind your button to call the sub/function in your module:

Private Sub MyNewButton_Click()
Call MySubRoutine()
End Sub

Ed Metcalfe.

Please do not feed the trolls.....
 
Thanks, Just tried that but didn't get anywhere (v.new to all of this!).. what's the exact syntax and how do I go about?

Public sub test() in a module called generateXML
if that helps?

Thanks again
 
Hi!
You need to make this a public function and then, in the On Click line of the property box for the button put:

=test()

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Or if your command button is called Command1 (for example):

Private Sub Command1_Click()
Call generateXML.Test
End Sub

If the routine doesn't return a value I'd argue it shouldn't be a function.

Ed Metcalfe.

Please do not feed the trolls.....
 
Thx guys! big help.. knew it couldn't be all that complicated, just v.new to access!

Thanks again.;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top