current record to be shown on the report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a command button which brings up a report containing all
the records in the database. I would like to show only the current record
being view on the form on the report.

How can I do this?
 
Look at this short description at
http://www.mvps.org/access/reports/rpt0002.htm.

From the page:
==========================
Print only the current record to a reportAuthor(s)
Dev Ashish

(Q) I'm trying to print out only the current record from my form in a report
but each time all the records print out. How can I print only one record
using a report?
(A) Use the OpenReport's Where condition to specify your record. For
example, the following code placed behind a command button on the form would
use the RunID control on the form to restrict the Report to only one record.
'******************** Code Start ************************
Dim strDocName As String
Dim strWhere As String
strDocName = "rptSomeReport"
strWhere = "[RunID]=" & me!RunID
DoCmd.OpenReport strDocName, acPreview, , strWhere
'******************** Code End ************************
===================================
 
Back
Top