Parameter for Report from Form



I created a form [EmployeeSelect] to hold the drop down box (Table
[EmployeeLog]![EmployeeName]) that I want my value chosen from and the code
for the button follows:

Private Sub ProjectsByIndividualReport_Click()
On Error GoTo Err_ProjectsByIndividualReport_Click

Dim stDocName As String
Dim pstrcriteria As String

stDocName = "ProjectbyMemberReport"
pstrcriteria = "[Enter Name] = """ &
Me.[Forms]![EmployeeSelect]![EmployeeName] & """"

DoCmd.OpenReport stDocName, acPreview, , pstrcriteria

Exit Sub

MsgBox Err.Description
Resume Exit_ProjectsByIndividualReport_Click

End Sub

[EnterName] is the Parameter for the query that the report draws from.

I keep getting a field not found error.

Can anyone help?

John Spencer

As far as I know, you cannot fill the parameter that way.

Either change the parameter in the reports source to

Or remove the parameter and change the criteria string to
pstrcriteria = "EmployeeName= """ & Me.[EmployeeName] & """"

By the way, I would use either

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Daryl S

I see you have both [Enter Name] and [EnterName] in your post - I suspect one
of these need to be changed to the real field name in your code.

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