If statement error

waq963

Registered User.
Local time
Today, 20:22
Joined
Jan 27, 2009
Messages
84
Hi, I have the following code below bet it comes up with a '424' error object required. I cant see what is wrong with the code. I have declared and set the recordset aswel. Any Ideas?

Code:
If rstP("V") Is Not Null Then
txtV.Value = DLookup("V", "tblP", "ID =""" & Forms![frmP]!cboP & """")
ElseIf rstP("W") Is Not Null Then
txtV.Value = DLookup("W", "tblP", "ID =""" & Forms![frmP]!cboP & """")
End If
 
you seem to have far to many quotes and to test for null in use the following recommended technique

IF Not IsNull(rstP("V") ) then
is not null is only used in queries.

If you want to substitute the contents of a combo box (or text control) then use a single quote

txtV.Value = DLookup("V", "tblP", "ID ='" & Forms![frmP]!cboP & '")
 
You didn't say what line threw the error, but try

If Not IsNull(rstP("V")) Then
 

Users who are viewing this thread

Back
Top Bottom