Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

recordset?

0 views
Skip to first unread message

Russ Hromyko

unread,
Nov 15, 2007, 9:14:02 PM11/15/07
to
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)


Dirk Goldgar

unread,
Nov 15, 2007, 9:23:31 PM11/15/07
to
In news:K17%i.14782$h61.10123@trndny02,

What error message are you getting, and what are the values of cboHours
and sqlStr when you get it?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Roger Converse

unread,
Nov 16, 2007, 4:48:01 PM11/16/07
to
Not sure, but I think this should work:

sqlStr = "SELECT * FROM dbo_LaserMachineMaintLog WHERE [LaserMachine] = " &

Me.cboLaserMachine & " AND [Hours] = '" & Me.cboHours & "';"

Set rs = db.OpenRecordset(sqlStr, dbOpenDynaset, dbSeeChanges)

0 new messages