I am trying to find a record in a table using an SQL statement in code.
Dim db As Database
Dim rst As Recordset
Dim strSQL As String
Dim strDate As String
Dim strTime As String
strDate = "#" & Me.Indate & "#"
strTime = "#" & Me.Intime & "#"
strSQL = "SELECT [order],[Date],[Time],[dpmt] FROM [Data2]"
strSQL = strSQL & "WHERE [Order] = '" & Me.order & "'"
strSQL = strSQL & " AND [time] = " & strTime
strSQL = strSQL & " AND [date] = " & strDate
strSQL = strSQL & " ORDER BY Data2.Date, Data2.Time"
Set rst = db.OpenRecordset(strSQL)
When run, I get an error msg. "Run Time Error 91"
"Object Variable or With Block Variable not set"
When I copy from the debug window and paste into query it works fine.
Any suggestions?
Dim db As Database
Dim rst As Recordset
Dim strSQL As String
Dim strDate As String
Dim strTime As String
strDate = "#" & Me.Indate & "#"
strTime = "#" & Me.Intime & "#"
strSQL = "SELECT [order],[Date],[Time],[dpmt] FROM [Data2]"
strSQL = strSQL & "WHERE [Order] = '" & Me.order & "'"
strSQL = strSQL & " AND [time] = " & strTime
strSQL = strSQL & " AND [date] = " & strDate
strSQL = strSQL & " ORDER BY Data2.Date, Data2.Time"
Set rst = db.OpenRecordset(strSQL)
When run, I get an error msg. "Run Time Error 91"
"Object Variable or With Block Variable not set"
When I copy from the debug window and paste into query it works fine.
Any suggestions?