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!

calling one form's subroutine from another form

Status
Not open for further replies.

CraigMan

Programmer
Apr 27, 2004
33
US
I've got 2 forms that I'm working with in Access 2000. Let's call them Form1 and Form2.

Form1 has a Sub that I'm trying to use from Form2. Let's call it Routine1. It has one argument Dim As String.

I called Routine1 in this manner:

Form_Form1.Routine1(string_variable)

The undesirable side-effect: runs Form_Load in Form1

Any ideas?
 
try something like the following in the Form1_FormLoad event:

Code:
If Form2.Visible then Exit Sub

I'm no Access expert, but I believe this will work. It has for me on several occasions in Excel.

If it doesn't work, then why not transfer the Procedure from Form1 into a standard code module instead?



Peace!! [americanflag] [peace] [americanflag]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Hi CraigMan,

You cannot avoid running event code when an event happens; that's the way it works! The best way forward really depends on why you are running code in the second Form. Does the called function have anything to do with the Form, or could it be a common routine in a Module instead? Or do you need both Forms loaded, in which case it is probably correct that the code in the Load event runs and you should probably look at your code and decide when it really should run and place it (or design it) appropriately.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
I thought I could get away with running one form's subroutine from another form. And didn't realize this triggered any form related events.

As both of you have mentioned, I just need to make it a generic module subroutine.

Thanks for your help.

I'm learning more about Access Forms with each passing keystroke in the code window!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top