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

Run Form's Onclick from another Form 1

Status
Not open for further replies.

KMKelly

Programmer
Jan 23, 2002
35
0
0
US
I have a report application that allows the user to open various forms, select criteria, and run a report. I need to print a selection of all of the reports for each division once a month, so I set up a main form called frmSet that opens each report form in sequence, sets the criteria that the report needs from that report form to open, and then opens the report directly in the code to the printer, and closes the form.

This works fine for all the reports that are based directly on queries, but I have a report that is based on a temporary table created as part of the on click for the button to open the report on its corresponding form. All the code is in that form (frmProv). It builds the custom SQL and creates a table, that is then queried by the report.

What I want to know is if there is any way to run that code in the frmProv form (essentially "click" that button) from the frmSet form. I want to be able to open the frmProv, set my criteria, run the code to create the temporary table, print the report, and close the form (frmProv) from the form frmSet.

Anyone know if this can be done?

Thanks.

Kris
 
Any Public procedure in a form's class module may be called as a method of the form object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
One trick that I have seen is to wrap your private procedures inside the forms module.

Private sub cmbo0_click()
your code
end sub

add this

Public sub cmbo0Click()
call cmbo0_click()
end sub

Now you can call your private procedure from the outside.

call form_form1.combo0Click

I have seen this done, but do not know the advantage over just making the original procedure public. In other words:
Public sub cmbo0_click()
They both work.

call form_form1.combo0_click()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top