Report for a single record

penfold

New member
Local time
Today, 18:07
Joined
Jan 26, 2001
Messages
5
I am working with a database that contains a large number of fields, where each record is a stand alone set of information. I have developed a report that puts all of the information database into a useful format, but I have not been able to limit the report to displaying only the record that is open in my form. It insists on displaying a report for every record, which is not useful to me. I would like to have a command button on my form that will open a report for the record displayed in the form, and for no other records, how can I do this?
 
You need to add a WHERE condition to your Docmd.OpenReport line.
Use your ID (Primary Key) field to uniquely identify the current record.....

docmd.OpenReport "MyReport",acViewPreview ,,"WHERE [MyID]=Forms![MyFormName]![MyID]"

HTH
 
I tried using the where function as you suggested, but I got the following error:

Syntax error (missing operator)in query expression '(WHERE [My ID]=Forms![MyForm]![MyID]'

Any suggestions?
 
Sorry, that should of been...

docmd.OpenReport "MyReport",acViewPreview ,,"[MyID]=Forms![MyFormName]![MyID]"
 

Users who are viewing this thread

Back
Top Bottom