-
I am using RDO to retrieve data from an Access database. When the data comes back, I need to handle the fact that some fields are 'Null'.
I try to core the following:
If RS1.Fields("SECONDARY_DIE") Is Null Then
txtSECONDARY_DIE.SetFocus
Else
txtSECONDARY_DIE.Text = RS1.Fields("SECONDARY_DIE")
txtSECONDARY_DIE.Locked = True
End If
... and get an error at the first line: 'Object required'. The field is empty and I really don't get what I am doing wrong.
Can anyone help on that ?
Thanks,
Francis
-
If you want to check for a null, try the isNull function.
Code:
If isNull(variable) Then
MsgBox "Variable is null."
End If
Hope this helps. :)
-
Stevie is correct. You need to use the isNull function. I think your error is generated by the isNull being in the wrong location. Your code is very close. Change it to look like this...
Code:
If isNull(RS1.Fields("SECONDARY_DIE")) Then
txtSECONDARY_DIE.SetFocus
Else
txtSECONDARY_DIE.Text = RS1.Fields("SECONDARY_DIE")
txtSECONDARY_DIE.Locked = True
End If
-
Or if you want to add recordset value to a Textbox, you can use this trick:
Code:
Text1.Text = "" & rs("FieldName").Value
This way you won't get an error saying that you cannot assign NULL to the Textbox.