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

how can 2 different forms use a single access report... 1

Status
Not open for further replies.

proggy

Programmer
Apr 21, 2002
46
US
Hello there..
I have 2 reports which have 10 sub reports in them and they take data from a main query ( whic is query by parameter)...
the problem is how can i use the same reports from 3 different forms..
I have a form which says print or preview the report.. the query takes the parametr from the form..
now if i have an other form which also has to use this query..
other that replicating the query any other way to do this ??
(can't replicate b'coz I have almost 30 queries and correcponding reports to be replicated)
thanks
 
After you enter the value on your form, assign it to a global variable, then have your query retrieve the value from the variable. This way the query won't care which form it came from.

1) In a module put the following (I don't know what data type your value is, so you can change the variant to String or Date of Integer if you want):

==========
Public gRptValue As Variant

Public Function GetRptValue() As Variant
GetRptValue = gRptValue
End Function
==========

Close and save it as whatever you want.

2) On the AfterUpdate Event of the text box on your forms, put the following:

==========
Private Sub MyTextBox_AfterUpdate()
gReportValue = Me.txtValue
DoCmd.OpenReport "MyReport", acPreview
End Sub
==========

3) In your queries, wherever you put the criteria that refers to the value on the form, put this instead:

=GetRptValue

This way, all you have to do is copy the After Update code (step 2) to any other forms, and it will work the same way. Jim Lunde
compugeeks@hotmail.com
We all agree your theory is crazy, but is it crazy enough?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top