How do I generate a report for a specific record?

  • Thread starter Thread starter Samantha
  • Start date Start date
S

Samantha

I am trying to generate a report based on the newest entry
in a form. I have already made a button on my form that
generates the report I need. However, the report is
returning info for all of the records and I would like it
to return only the info for the record that has just been
entered.

Please Help! Thanks,
Samantha
 
Samantha,

You will need to add a Where Condition to the OpenReport method so that the
report shows only the information for the record displayed on your form.
For example, if the current record on your form was for a particular
customer, you could use the CustID field to determine the where condition as
follows:

Dim strCriteria As String

' This works when your matching field is text
strCriteria = "[CustID] = " & Chr(34) & Me!CustID & Chr(34)
DoCmd.OpenReport "MyReport", acViewNormal, , strCriteria

' This works when your matching field is a number
strCriteria = "[CustID] = " & Me!CustID
DoCmd.OpenReport "MyReport", acViewNormal, , strCriteria

hth,
 
Back
Top