J
Joel
I am trying to use a SQL query as the parameter to open a recordset.
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb()
Set strSQL = "SELECT TOP 1 Vehicles.EmployeeID, Vehicles.InsuCompany,
Vehicles.InsuFirstName, Vehicles.InsuLastName, Vehicles.InsuAddress,
Vehicles.InsuCity, Vehicles.InsuState, Vehicles.InsuZip,
Vehicles.PolicyNumber, Vehicles.InsuEffectiveDate,
Vehicles.InsuExpirationDate " & _
"FROM Vehicles " & _
"WHERE [Vehicles].[EmployeeID] = " & [Forms]![Employees]![tbEmployeeID] & ";"
Set rst = db.OpenRecordset(strSQL)
I get the error "Compile Error: Object required" at this part
" & [Forms]![Employees]![tbEmployeeID] & ";"
I setup a msgbox to display tbEmployeeID and it displays it so I don't why
its giving me an object error.
Can anyone explain this?
Thanks
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb()
Set strSQL = "SELECT TOP 1 Vehicles.EmployeeID, Vehicles.InsuCompany,
Vehicles.InsuFirstName, Vehicles.InsuLastName, Vehicles.InsuAddress,
Vehicles.InsuCity, Vehicles.InsuState, Vehicles.InsuZip,
Vehicles.PolicyNumber, Vehicles.InsuEffectiveDate,
Vehicles.InsuExpirationDate " & _
"FROM Vehicles " & _
"WHERE [Vehicles].[EmployeeID] = " & [Forms]![Employees]![tbEmployeeID] & ";"
Set rst = db.OpenRecordset(strSQL)
I get the error "Compile Error: Object required" at this part
" & [Forms]![Employees]![tbEmployeeID] & ";"
I setup a msgbox to display tbEmployeeID and it displays it so I don't why
its giving me an object error.
Can anyone explain this?
Thanks