Report for single record

  • Thread starter Thread starter lmcgowan
  • Start date Start date
L

lmcgowan

Guest
I want to have a comand button on my form which will create a report for a single record. Is this possible or will the report only includ all the records in that table.
 
You would define which record you would want to print using Criteria like -


DoCmd.OpenReport "MyReport",acViewNormal,,"[MyField]=Forms!MyForm!MyField"


The last bit is the Criteria and is basically -

[MyField] is the name on the unique fieldname of the record that identifies the record you want to print - it could be the Primary Key.

Forms!MyForm!MyField is the place where the value of MyField is to be found. In this case, On a form called 'MyForm' in a control called 'MyField'

This method assumes that the record has already been selected on a form prior to printing. The Report name here is 'MyReport'.

If the field to be used in the Criteria is on a subform then the code would be different, like -


DoCmd.OpenReport "MyReport",acViewNormal,,"[MyField]=Forms!MyForm!MySubform.Form.MyField"


HTH

Dave E
 

Users who are viewing this thread

Back
Top Bottom