D
Dave Elliott
I have a main form (frmAutoPayrollReport) that opens another form
(Timecards) with criteria from drop down lists.
The drop down list name is Client, it is unbound
On the lookup form (Timecards) where it opens with the criteria chosen from
main form (frmAutoPayrollReport) the control for the client is Client ID
with a table/query lookup.
The below code is in a module called ModLookUp that is called from the on
click event of the main form.(frmAutoPayrollReport)
It does not work, Why? The field Client ID is in the query QDates
Dim db As DAO.Database
Dim qd As QueryDef
Dim Mywhere As Variant, Var1 As Variant
Var1 = [Forms]![frmAutoPayrollReport]
Set db = DBEngine.Workspaces(0).Databases(0)
On Error Resume Next
db.QueryDefs.Delete ("QDynamicQuery")
On Error GoTo 0
Mywhere = Mywhere & (" And [Client ID]Like '" + Var1![Client] + "'")
Set qd = db.CreateQueryDef("QDynamicQuery", "Select * From QDates " &
("Where " + Mid(Mywhere, 6) + "ORDER BY [TimeCounter] ASC ;"))
DoCmd.OpenForm "TimeCards"
LookUp_Exit:
Exit Function
LookUp_Err:
MsgBox Error$
Resume LookUp_Exit
End Function
(Timecards) with criteria from drop down lists.
The drop down list name is Client, it is unbound
On the lookup form (Timecards) where it opens with the criteria chosen from
main form (frmAutoPayrollReport) the control for the client is Client ID
with a table/query lookup.
The below code is in a module called ModLookUp that is called from the on
click event of the main form.(frmAutoPayrollReport)
It does not work, Why? The field Client ID is in the query QDates
Dim db As DAO.Database
Dim qd As QueryDef
Dim Mywhere As Variant, Var1 As Variant
Var1 = [Forms]![frmAutoPayrollReport]
Set db = DBEngine.Workspaces(0).Databases(0)
On Error Resume Next
db.QueryDefs.Delete ("QDynamicQuery")
On Error GoTo 0
Mywhere = Mywhere & (" And [Client ID]Like '" + Var1![Client] + "'")
Set qd = db.CreateQueryDef("QDynamicQuery", "Select * From QDates " &
("Where " + Mid(Mywhere, 6) + "ORDER BY [TimeCounter] ASC ;"))
DoCmd.OpenForm "TimeCards"
LookUp_Exit:
Exit Function
LookUp_Err:
MsgBox Error$
Resume LookUp_Exit
End Function