Specific Report

  • Thread starter Thread starter Oli
  • Start date Start date
O

Oli

Hi,

I want a CommandButton on my Form that when pressed takes the details of the
current record and inputs them into a report and automatically prints it to
the default printer.

I only want the report for that particular record printing - not all records
in the DB.

Can you guys point me in the right direction?

TIA
Oli
 
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