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

Form to report - how to pass the current record

Status
Not open for further replies.

datavisions

Programmer
May 30, 2001
35
CA
I'm going to sound like a total idiot, but I have:

a simple customer quote form (frmQuote) for the table (key CustomerID), and on the form I have a button that, on click, does a DoCmd.OpenReport to preview the report (rptQuote) with the source qryQuote. When I wrote it, the select is on [Forms]![frmQuote]![CustomerID] which I was just typing in during testing, but now I'm confused as to how to tie it in to the current CustomerID on the frmQuote.

Sorry to ask such a silly question!
 
You should be able to keep the [Forms]![frmQuote]![CustomerID] in the report's query to show the current record in the form. Alternatively, you could remove the criteria from the query and pass it via the WhereCondition argument of the DoCmd.OpenReport method, as follows:

Dim Criteria as String

Criteria = "CustomerID=" & [CustomerID]
DoCmd.OpenReport ReportName:="rptQuote", WhereCondition:=Criteria

Note: I'm assuming the CustomerID is a numeric value (you'll need to wrap quotes around the value if it's text)

This is a more flexible approach since you can filter the report on different fields.

Hope this helps
 
I can't thank you enough! It works like a charm and I have a gazillion docs that I can now tie-in this way.

Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top