Report Button on Form

G

Guest

How do I get my Preview report button to recoginze the specific file or Id
number that I am in? For Example if I write an estimate for Joe and click the
preview report button it starts at the beginiing of the database with the
first estimate it does not go directly to Joe's I must scrool over to get to
it, when I print, it prints all of the reports not just Joe's. I want it to
take me to the report I am working with and just print the report I am
working with. I know that I can adjust print settings every time but thats
not user friendly. Thank you for help
 
F

fredg

How do I get my Preview report button to recoginze the specific file or Id
number that I am in? For Example if I write an estimate for Joe and click the
preview report button it starts at the beginiing of the database with the
first estimate it does not go directly to Joe's I must scrool over to get to
it, when I print, it prints all of the reports not just Joe's. I want it to
take me to the report I am working with and just print the report I am
working with. I know that I can adjust print settings every time but thats
not user friendly. Thank you for help

Your table should have a unique prime key field.

If so, code the command button's Click event:

' First save the new record data
DoCmd.RunCommand acCmdSaveRecord

' Then open the report
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'
 
G

Guest

Dear fredg .

Thank you, for taking the time to respond to my post, that worked perfectly.

Sincerely,
Demo-man

fredg said:
How do I get my Preview report button to recoginze the specific file or Id
number that I am in? For Example if I write an estimate for Joe and click the
preview report button it starts at the beginiing of the database with the
first estimate it does not go directly to Joe's I must scrool over to get to
it, when I print, it prints all of the reports not just Joe's. I want it to
take me to the report I am working with and just print the report I am
working with. I know that I can adjust print settings every time but thats
not user friendly. Thank you for help

Your table should have a unique prime key field.

If so, code the command button's Click event:

' First save the new record data
DoCmd.RunCommand acCmdSaveRecord

' Then open the report
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'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top