Print Current report

B

Bg

I have an access db with 35+ names and addresses. In this db I have a form
which data is entered, of course. On this form I added a command button to
print a report. The report is based on a query that asks for the ID number
to select just one name, address, etc. The problem I have, is that when the
command button is clicked, a box comes up asking for this ID number, as it
would for the query and report. While this is not a huge problem...Id like
to configure the command button to print the current info on the form
(i.e.record number)
Hope this makes sense.
 
D

Duane Hookom

I don't generally add any criteria like this in a report's record source
query. In a case like this, I would use code with the command button like:
Dim strWhere as String
strWhere = "ID=" & Me.txtID
DoCmd.OpenReport "rptYourReport", acPreview, , strWhere
This code assumes
-your field name is ID
-you have a text box bound to the ID field named txtID
-your field in numeric
-your report name is "rptYourReport"
-you want the report to open in preview mode
 
B

Bg

Got it...thanks very much!
Bg
Duane Hookom said:
I don't generally add any criteria like this in a report's record source
query. In a case like this, I would use code with the command button like:
Dim strWhere as String
strWhere = "ID=" & Me.txtID
DoCmd.OpenReport "rptYourReport", acPreview, , strWhere
This code assumes
-your field name is ID
-you have a text box bound to the ID field named txtID
-your field in numeric
-your report name is "rptYourReport"
-you want the report to open in preview mode
 

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