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

Beginner question

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm building an application that will make a manual process an automated one using vb coding in MS Access. But I'm getting stuck on the very beginning. How do I call my sub from, say the form button? It wants a function name, but that's in a module and Access is complaining that it can't find the module. I must be calling it incorrectly.

Thanks for your help and for bearing with such a beginner question,
Scott
 
The easiest way to call a sub from a button on a form is to go into Design view on the form, and click on the button in question, then choose properties either from the toolbar or by right clicking. Go to the "events" tab in the properties dialog, and on the corresponding event...say "On Click" to capture when you click on the button, choose "Event procedure"

You can then click on the button to the right, I think it's called the build button, it has "..." on it. That will take you to the form's module, and to the sub already pre-filled in that corresponds with the relevant event.

ie.
the command button on your form is called 'cmdTest'.

When you hit the build button, next to the 'On Click' event, you will be taken to the following sub in your module.
Code:
Private Sub cmdTest_Click()

End Sub

In that subroutine you can enter the code you want to run.

Have you gotten this far already?
-Dan
 
Scott_in_CT,

Private Sub mybutton_Click()
Dim myvariable as Variant
myvariable = MyProceedure()
End Sub
 
Thanks guys, that works! Now I'm going to be dangerous!!! :^)

Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top