How do I call a sub routing with a control button?

Merlin

New member
Local time
Today, 14:57
Joined
Jul 11, 2002
Messages
9
How do I call a sub routing with a command button?

I have a routine written to input a user entered number into one of the fields in all records, but I can't get it to trigger. I thought I read where I had to use a function procedure that called the sub procedure. Can any one give me some sample code on how to do this?

Many thanks

Merlin
 
Last edited:
If you are using a control button, wouldn't it be in the OnClick event procedure?

Col
 
You would think so but it doesn't work. I am, I confuse, a newbie. Neither the module nor the procedure are activate this way. I am reading up on the issue and the book (Running Access) says you can only call a function and not a sub function this way. But i don't know how to write a funtion that calls a sub function.

Need more time to get the hang of this VBA...feel like I'm learning to play the violin...at the recital!!


Thanks
 
You would think so but it doesn't work. I am, I confuse, a newbie. Neither the module nor the procedure are activate this way. I am reading up on the issue and the book (Running Access) says you can only call a function and not a sub function this way. But i don't know how to write a funtion that calls a sub function.

Need more time to get the hang of this VBA...feel like I'm learning to play the violin...at the recital!!


Thanks
 
Private Sub Command01_Click()
mySubFunction
End Sub

Command01 of course would be the name of your command button. And mySubFunction would be the name of the Sub your calling.

Also, make sure that the Sub you are calling is a Public Sub and not Private to another form.

You may have to post what you have that doesn't seem to be working in order for us to assist in finding out why.

Peace
 

Users who are viewing this thread

Back
Top Bottom