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

Shared VB code between reports

Status
Not open for further replies.

btrini10

IS-IT--Management
Dec 5, 2006
73
US
Hi, I have a form that allows a user to select a combination of criteria to print any one of a variety of reports. I then create a Where clause using VB based on the selection. The format of each report is different, but the Where clause that is built in VB is the same for all reports. I am new to VB and not sure how to code this. I guess I would like to create a module and have that same module called for each report. Any help is appreciated.
 
Use the 4th parameter of the DoCmd.OpenReport method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV, I already have one report that is using the Where clause. I would like another report to be opened using the same where clause if the user chooses to run that report. Currently, the code that creates the where clause is associated with a button that opens one report. I am trying to avoid copying the code to each button's on clisk action.
 
How are ya btrini10 . . .

In a module in the modules window [blue]return the criteria in a Public function[/blue], and use that as the fourth parameter of DoCmd.OpenReport (already stated by [blue]PHV[/blue]). Example
Code:
[blue]Public Function ComCriteria() As String
   ComCriteria = [green]'your code for criteria[/green]
End Function[/blue]
Calling a report would look like:
Code:
[blue]   DoCmd.OpenReport "ReportName", acViewPreview, , [purple][b]ComCriteria()[/b][/purple][/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top