TheSearcher
Registered User.
- Local time
- Today, 16:28
- Joined
- Jul 21, 2011
- Messages
- 385
The code below returns a null string (as it should) in query design.
However, in my VBA code the vartype for rs("Number_UnitsBilled") is 9 which indicates that it is returning an object. Therefore, the program crashes with a "No current Record" error in the "Else" statement. How can this be?
However, in my VBA code the vartype for rs("Number_UnitsBilled") is 9 which indicates that it is returning an object. Therefore, the program crashes with a "No current Record" error in the "Else" statement. How can this be?
Code:
sql2 = "SELECT tbl_Billing.Number_UnitsBilled, tbl_Billing.ID "
sql2 = sql2 & "From tbl_Billing "
sql2 = sql2 & "WHERE (tbl_Billing.Client_Id = '" & Client & "') "
sql2 = sql2 & "AND (tbl_Billing.Date_Of_Service = #" & DOS & "#) "
sql2 = sql2 & "AND (tbl_Billing.Payer = 'MLTSS') "
sql2 = sql2 & "AND (tbl_Billing.Therapy = 'Structured Day');"
Set rs2 = db.OpenRecordset(sql2)
MsgBox "Vartype: " & VarType(rs2("Number_UnitsBilled"))
'Vartype 9 = Object
If IsNull(rs2("Number_UnitsBilled")) = True Then
SDBilled = 0
Else
SDBilled = rs2("Number_UnitsBilled")
End If