Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » References to DB fields in If statement not working
References to DB fields in If statement not working
Resolved · Medium Priority · Version 2003
Simon has attended:
No courses
References to DB fields in If statement not working
I've got the following code in a module that deletes data. I've stepped through this and even when both parts of the IF are true the code steps over the delete statement (jumping straight to the endif).
With rstDBTarget
.MoveFirst
Do While Not .EOF
If .Fields("VolID") = iVolID AND _
.Fields("ReqID") = Me.ReqID Then
Debug.Print "Deleted one"
.Delete
.Update
End If
End If
.MoveNext
Loop
End With
Is there a problem with referring directly to the rst fields in the IF clause?
Thanks.
For upcoming training course dates see: Pricing & availability
RE: References to DB fields in If statement not working
Ah! Found the problem. iVolID was populated from a list field and, in spite of declared data type, was a string not an integer. Once I coerced the data using Clng it worked.
|
