running a routine from another form

folkie

Registered User.
Local time
Today, 06:16
Joined
May 31, 2002
Messages
43
I have 3 forms that run different reports. All 3 forms have a command button that runs several (make table and append) queries - the same several queries. I've been testing the command button that updates the tables (along with a progress meter) on one of the forms. That works fine on the one form.

In order to get the code working on the other forms, I could copy and paste the code I have and put that code on command buttons on the other 2 forms. But I figured there must be a way to just have the code in 1 place (in the event procedure of the command button I've tested) and then have the other command buttons just run that original code.

The original command button that works is on a form called fReportsAllFunds. The command button's name is UpdateTables2. The event procedure runs when the command button is clicked, thus the sub-routine is called UpdateTables2_Click(). Originally is was a Private Sub.

In the new command button, I've tried all kinds of syntax, but keep getting errors. One error message led me to something saying the original routine shouldn't be Private, so I made it Public. That didn't work. I've tried ! and . and [], but can't figure it out.

Do you know how I can run code (other than copying and pasting) behind a command button that comes from another form?
 
Create a Public Function in a module to do what you want then you can call it from any form.

hth,
Jack
 
Thanks Jack. That worked. I'm sloooooowly learning.
 
You are welcome and I am glad you have your code working....

Jack
 

Users who are viewing this thread

Back
Top Bottom