same report triggered from different forms

G

Gabi

Hi,

In my database, one report can be viewed by clicking a button on two forms.
The report is based on a query, that brings the value of a field [CID] from
the forms. Now, I make 2 duplicate both the query and the report into 2
versions; in query1, the criteria is CID=[Form1]![CID], in query2, the
criteria is CID=[Form2]![CID].

I just wonder if there is a more clever way to do this.

Thanks.
 
D

Duane Hookom

I try to not place form control references in criteria of both form and
report record sources. Most situations allow you to supply a where clause in
the DoCmd.OpenReport method. For instance:

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.CID) Then
strWhere = strWhere & " And [CID]=" & Me.CID
End If
DoCmd.OpenReport "rptYourReport", acPreview, , strWhere

As you can see, you can open the report from anywhere since the report's
record source doesn't reference controls on forms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top