OpenReport command not picking up parameters from form control

Margarita

Registered User.
Local time
Today, 17:35
Joined
Aug 12, 2011
Messages
185
Hello, I have to apologize in advance for posting yet another thread on docmd.openreport, but I just could not find what I am doing wrong from the dozens of threads that I browsed. Here is my goal and my problem (working in Access 2003):

I have a form which lists employees in a combobox. I pick one employee, the month for which I want to check his/her FTE value (a value that measures his/her effort in a given task in a given month.) I pick a name and the month from combobox controls, and click the CheckFTE button to run a report on this month's FTEs. In the on-click even I have the code below that is supposed to open an existing report called CheckFTEperemployee, which is based on a stored query- a simple select statement from the EmployeeFTE table. Here is the code:

PHP:
Private Sub checkcurrentFTEbutton_Click()
If IsNull(Me![EmployeeName]) Or IsNull(Me![worktimetype]) Or IsNull(Me![ftemonthstart]) Then
    MsgBox "Please fill in all required fields to run a check of employee's FTEs."
Else
 DoCmd.OpenReport "CheckFTEperemployee", acViewPreview, , "(LastName ='" & Me![EmployeeName].Column(1) & _
    "' And FirstName = '" & [EmployeeName].Column(2) & _
    "' And WorkTimeType = '" & [worktimetype] & _
    "' And FTEMonthStart = #" & [ftemonthstart] & "#)"
End If

When I try to run this, I get asked for the LastName and FirstName as if they are parameters- which tells me that the paratemeters from the control aren't being picked up. As far as I can see, all my formatting is correct and exactly mirrors the formatting in the help files and in the threads that I've read. The fields FirstName, Lastname, WorkTimeType, and FTEMonthStart are all fields in the report's underlying query and the names are the same, so I don't see why the 'Where' criteria isn't being applied. Just a note: I know that the index of the first column in a combox is 0, not 1. I am deliberately using 1 and 2 here because my first and last names are stored in the second and third columns on the combobox (the first one displays the concatenated first and last name).

Thank you in advance for any assistance!
 
Are any of these checking the value(s) from the combobox? If so, which one(s)?
What is the name of the combo?
I'm confused by what exactly Me!EmployeeName and Me![EmployeeName].Column(1) represent and why the Me! has been dropped from [EmployeeName].Column(2) and others. Seems there was a change in syntax for some reason.
 
Are any of these checking the value(s) from the combobox? If so, which one(s)?
What is the name of the combo?
I'm confused by what exactly Me!EmployeeName and Me![EmployeeName].Column(1) represent and why the Me! has been dropped from [EmployeeName].Column(2) and others. Seems there was a change in syntax for some reason.

Hello, yes you are correct- I tried many different syntax versions- I just forgot to put the me!'s back when I pasted the code into the thread.
To answer your question- [EmployeeName].Column(2) refers to the third column of the combobox EmployeeName- this is the column that holds the FirstName field.
Any ideas where I'm mesisng up? Thank you!
 

Users who are viewing this thread

Back
Top Bottom