Use open record to filter report

S

Sandy

I have form that displays one record at a time. I have built a report based
off of that form. The user would click on a command button to pull up this
report. I need this report only to pull up the active record, not all
records. How do I get the report to just pull up the info for that one
record?
 
J

Jackie L

The easiest way, in my opinion, is to create a query with the table from your
report. On the criteria line, under the field which identifies that record,
use your expression builder to point to the field on your form. It would
look like:
Forms![frmInputData]![DataID]

Then use the query as your record source for your report.

Hope this helps.
 
F

fredg

I have form that displays one record at a time. I have built a report based
off of that form. The user would click on a command button to pull up this
report. I need this report only to pull up the active record, not all
records. How do I get the report to just pull up the info for that one
record?

Your table should have a unique prime key field.

If so, code the command button's Click event:
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If [RecordID] is Text Datatype, then use:

"[RecordID] = '" & [RecordID] & "'"

as the Where clause.
Change the field name to whatever the actual field name is that you
are using.

See Access Help files for:
Where Clause + Restrict data to a subset of records'
 
Top