Parameter for Report from Form


H

hntsignif

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_ProjectsByIndividualReport_Click:
Exit Sub

Err_ProjectsByIndividualReport_Click:
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?
 
Ad

Advertisements

J

John Spencer

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

Either change the parameter in the reports source to
[Forms]![EmployeeSelect]![EmployeeName]

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

By the way, I would use either
Me.[EmployeeName]
or
[Forms]![EmployeeSelect]![EmployeeName]

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

Advertisements

D

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

Top