Printing Report for one a single record - Several problems

N

NDClark

Guys, I am having several issues here. Please be patient with me.
I have a form named : Evaluation Form
I have a report named : Evaluation
The table is named: Evaluation

What I am wanting to do is click the Print button on a form where I have
entered data and print a single record off of a report that is linked to the
data.

I have a button named 'Print1' on the form. I have tried the code several
different ways and come to different problems each time I change it.
---------------------------------------------------------------------------
"This will get me a dialog box asking for a parameter."
The code I added to the button is as follows:

Private Sub Print1_Click()
DoCmd.OpenReport "Evaluation", acPreview
Reports![Evaluation].Filter = "Officer = " & Me![Officer]
Reports![Evaluation].FilterOn = True
End Sub
______________________________________________________________
"This gets me an error in the debug of 'cant find the field 'ID' in the
expression."
I tried this code:

Private Sub Print1_Click()
DoCmd.OpenReport "Evaluation", acPreview
Reports![Evaluation].Filter = "ID = " & Me![ID]
Reports![Evaluation].FilterOn = True
End Sub

--------------------------------------------------------------------------------------
 
P

pietlinden

You don't apply the filter after you open the report. You have to
specify it WHEN you open the report. one of the arguments of the Open
event of the report is the filter

Public Sub OpenMyReport()
Dim strFilter As String
strFilter = "[EmployeeID] = Forms!frmEmployee!cboEmployeeID"
DoCmd.OpenReport "EmployeeReport", acViewPreview, , strFilter,
acWindowNormal
End Sub
 
L

Lynn Trapp

I don't care much for the Filter property of a report and, instead, I do the
filtering in the record source of my reports. The syntax for setting the
criteria in your query would be:

Forms![Evaluation Form]![ID]
 
N

NDClark

Lynn, you lost me. Should I scrap my code?
If so you say go to the Record Source. Should I create a query in the
Record Source of the Report?

Lynn Trapp said:
I don't care much for the Filter property of a report and, instead, I do the
filtering in the record source of my reports. The syntax for setting the
criteria in your query would be:

Forms![Evaluation Form]![ID]

--
Lynn Trapp
MCP, MOS, MCAS


NDClark said:
Guys, I am having several issues here. Please be patient with me.
I have a form named : Evaluation Form
I have a report named : Evaluation
The table is named: Evaluation

What I am wanting to do is click the Print button on a form where I have
entered data and print a single record off of a report that is linked to the
data.

I have a button named 'Print1' on the form. I have tried the code several
different ways and come to different problems each time I change it.
---------------------------------------------------------------------------
"This will get me a dialog box asking for a parameter."
The code I added to the button is as follows:

Private Sub Print1_Click()
DoCmd.OpenReport "Evaluation", acPreview
Reports![Evaluation].Filter = "Officer = " & Me![Officer]
Reports![Evaluation].FilterOn = True
End Sub
______________________________________________________________
"This gets me an error in the debug of 'cant find the field 'ID' in the
expression."
I tried this code:

Private Sub Print1_Click()
DoCmd.OpenReport "Evaluation", acPreview
Reports![Evaluation].Filter = "ID = " & Me![ID]
Reports![Evaluation].FilterOn = True
End Sub

--------------------------------------------------------------------------------------
 
T

Tom Wickerath

You don't apply the filter after you open the report. You have to
specify it WHEN you open the report.

Well, one *can* apply a filter after opening the report, but it really
doesn't make a lot of sense to do so, especially if a network separates you
from your data. I agree that using the optional WhereCondition parameter
makes a lot more sense.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

You don't apply the filter after you open the report. You have to
specify it WHEN you open the report. one of the arguments of the Open
event of the report is the filter

Public Sub OpenMyReport()
Dim strFilter As String
strFilter = "[EmployeeID] = Forms!frmEmployee!cboEmployeeID"
DoCmd.OpenReport "EmployeeReport", acViewPreview, , strFilter,
acWindowNormal
End Sub
 

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