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!

Procedure Call 2

Status
Not open for further replies.

SanAntonioSpurFan

Instructor
Oct 21, 2003
83
US
I have a form called F1 that opens first. User clicks command button and opens Form2. Procedure is run to dump data to Excel and closes Form2. I want to call a procedure in F1 before F2 closes but it tells me Sub or Function not defined. I need this Sub to be located in F1 becasue it gathers its info there. If I can't call from F2, when F2 is closed call F1 call it in the same command button click?

 
Hi SanAntonioSpurFan,

To call a procedure in another (open) Form, you must qualify it. Otherwise it will only be looked for in Modules.

Code:
[blue]Call Forms![[i]Form1[/i]].[i]ProcInForm1[/i][/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Hi SanAntonioSpur Fan and TonyJollans

I am trying to do the same basic thing as discussed in this thread, but with my code:

Call Forms!Equipment.Selected_Equipment_AfterUpdate

I keep getting an error message on compiling
"Compile error - wanting . or ("

I am trying to call procedure Selected_Equipment_AfterUpdate in a form called "Equipment" whilst running a procedure in a subform of "Equipment" - will this Call process not work between a main and subform?

Thanks for any advice
John
 
Isn't Selected_Equipment_AfterUpdate a Private procedure ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Dear PHV

If what you mean by a private procedure is that it is actioned on the AfterUpdate event of a textbox called "Selected_equipment", then yes.

If this is the problem how do I make my procedure more global so that my subform procedure can call it - do I do it on the form level or must I create a module?

Sorry if this is a basic question, but I am still trying to learn this coding stuff and my Access help files are in German (which I can't read!).

John
 
Hi johnbucks,


Only Public Procedures are accessible from other modules. Event Procedures are, by default, Private - thay are only available for use within the Form's Class Module. They are defined like this ..

Code:
[blue][red]Private[/red] Sub Selected_Equipment_AfterUpdate()[/blue]

I'm not sure I'd recommend it, but you can make them Public explicitly ..

Code:
[blue][red]Public[/red] Sub Selected_Equipment_AfterUpdate()[/blue]

.. or implicitly by simply removing the Private keyword

Code:
[blue]Sub Selected_Equipment_AfterUpdate()[/blue]


Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top