Parameter for Report from Form

  • Thread starter Thread starter hntsignif
  • Start date Start date
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?
 
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
 
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.
 
Back
Top