R
Russ Hromyko
Can anyone tell me why this is happening, when I use an actual number, 47731
for the [Hours] everything works, but when I use Me.cboHours I get an error
message? What am I missing and how do I make Me.cboHours work? When I hit
debug on the error message it points to the recordset (Set rs = ). Below
the dotted line is not part of the code, it's the code I want to work.
Private Sub cboHours_AfterUpdate()
Dim sqlStr As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
sqlStr = "SELECT * FROM dbo_LaserMachineMaintLog WHERE [Laser Machine] =
" & _
"'" & Me.cboLaserMachine & "' " & "AND [Hours] = 47731"
Set rs = db.OpenRecordset(sqlStr, dbOpenDynaset, dbSeeChanges)
'---------------------------------------------------------------------------------------------------------------------------------------------
sqlStr = "SELECT * FROM dbo_LaserMachineMaintLog WHERE [Laser Machine] = " &
_
"'" & Me.cboLaserMachine & "' " & "AND [Hours] = " & Me.cboHours
Set rs = db.OpenRecordset(sqlStr, dbOpenDynaset, dbSeeChanges)
for the [Hours] everything works, but when I use Me.cboHours I get an error
message? What am I missing and how do I make Me.cboHours work? When I hit
debug on the error message it points to the recordset (Set rs = ). Below
the dotted line is not part of the code, it's the code I want to work.
Private Sub cboHours_AfterUpdate()
Dim sqlStr As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
sqlStr = "SELECT * FROM dbo_LaserMachineMaintLog WHERE [Laser Machine] =
" & _
"'" & Me.cboLaserMachine & "' " & "AND [Hours] = 47731"
Set rs = db.OpenRecordset(sqlStr, dbOpenDynaset, dbSeeChanges)
'---------------------------------------------------------------------------------------------------------------------------------------------
sqlStr = "SELECT * FROM dbo_LaserMachineMaintLog WHERE [Laser Machine] = " &
_
"'" & Me.cboLaserMachine & "' " & "AND [Hours] = " & Me.cboHours
Set rs = db.OpenRecordset(sqlStr, dbOpenDynaset, dbSeeChanges)