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:
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!
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!