Hi,
I have what seems to be a pretty complicated issue so I'll try and explain it as best i can.
I have a query (that gets it's data from several other queries) with a column called "max." The data in the column is correct, but when I call on the query in VBA, it shows me incorrect data.
Here is where I call the query:
Let me explain.. The query looks at a table of employees and finds out if they have been issues a warning letter before, then prints out a corresponding report based on the "max" warning level they are at.
The problem arises when an employee graduates from a 6 month probation period - all letters in that period should be ignored. As i said, they are ignored correctly when i run and view my query ("7-ErrorsReport") because they are filtered out at that point, but for some reason when this code runs, it somehow sees the previously issued letters which are stored in a table and likely in some of the other queries.
I am not sure if there is some issue with the query tree I have set up which is necessary to get the results I need, or if something is wacked with the was I am using it as a recordsource.
Any help would be appreciated, please let me know if you require any more info.
THanks,
I have what seems to be a pretty complicated issue so I'll try and explain it as best i can.
I have a query (that gets it's data from several other queries) with a column called "max." The data in the column is correct, but when I call on the query in VBA, it shows me incorrect data.
Here is where I call the query:
Code:
Dim db As DAO.Database, qdf As DAO.QueryDef, rs As DAO.Recordset
Dim strReport As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("7-ErrorsReport")
qdf.Parameters(0) = Forms!frmmain!dt1.Value
qdf.Parameters(1) = Forms!frmmain!dt2.Value
qdf.Parameters(2) = Forms!frmmain!d2.Value
qdf.Parameters(3) = Forms!frmmain!probationvar
qdf.Parameters(4) = Forms!frmmain!s1.Value
qdf.Parameters(5) = Forms!frmmain!d1.Value
qdf.Parameters(6) = Forms!frmmain!errnumvar
qdf.Parameters(7) = Forms!frmmain!site.Value
qdf.Parameters(8) = Forms!frmmain!site2.Value
qdf.Parameters(9) = Forms!frmmain!site3.Value
qdf.Parameters(10) = Forms!frmmain!site4.Value
qdf.Parameters(11) = Forms!frmmain!site5.Value
qdf.Parameters(12) = Forms!frmmain!errpercvar
Set rs = qdf.OpenRecordset
rs.MoveFirst
Do While Not rs.EOF
Select Case rs.Fields("max")
Case 1
strReport = "Errors1"
Case 2
strReport = "Errors2"
Case 3
strReport = "Errors3"
Case Else
strReport = "Errors0"
End Select
DoCmd.OpenReport strReport, , , "employeeID=" & rs!employeeID
rs.MoveNext
Loop
Set rs = Nothing
Exit Sub
Let me explain.. The query looks at a table of employees and finds out if they have been issues a warning letter before, then prints out a corresponding report based on the "max" warning level they are at.
The problem arises when an employee graduates from a 6 month probation period - all letters in that period should be ignored. As i said, they are ignored correctly when i run and view my query ("7-ErrorsReport") because they are filtered out at that point, but for some reason when this code runs, it somehow sees the previously issued letters which are stored in a table and likely in some of the other queries.
I am not sure if there is some issue with the query tree I have set up which is necessary to get the results I need, or if something is wacked with the was I am using it as a recordsource.
Any help would be appreciated, please let me know if you require any more info.
THanks,