-
When I run the following code:
With rsPI
txtFSN.Text = !FSN
txtFirst.Text = !First_Name
txtLast.Text = !Last_Name
medSSN.Text = !Soc_Sec
txtMI.Text = !MI_Name
...
I get "Run time error '94': Invalid use of Null" with the
debug pointing to the "txtFSN.Text = !FSN" line. If I comment that out and rerun it, I get the same error on the "txtMI.Text = !MI_Name" line. With that line (and the following assignment lines) commented out, the form displays OK.
Can someone explain the concept of "Null" as used in this error message? And what I need to do to correct the problem?
-
<?>
Your database field has a null value
change
I think this will work
txtFsn.datafield = format(rs("Field"))
-
You need to check for the return from your recordset is a NULL string before you assign it to the textbox control
You can do it both way... But the IIF will be a bit slow, because it check both True and False condition before it make the decission
Code:
With rsPI
txtFSN.Text = IIf(IsNull(!FSN), "", !FSN)
txtFirst.Text = IIf(IsNull(!First_Name), "", !First_Name)
txtLast.Text = IIf(IsNull(!Last_Name), "", !Last_Name)
medSSN.Text = IIf(IsNull(!Soc_Sec), "", !Soc_Sec)
txtMI.Text = IIf(IsNull(!MI_Name), "", !MI_Name)
End With
OR
Code:
With rsPI
If IsNull(!FSN) Then
txtFSN.Text = ""
Else
txtFSN.Text = !FSN
End If
If IsNull(!First_Name) Then
txtFirst.Text = ""
Else
txtFirst.Text = !First_Name
End If
If IsNull(!Last_Name) Then
txtLast.Text = ""
Else
txtLast.Text = !Last_Name
End If
If IsNull(!Soc_Sec) Then
txtmedSSN.Text = ""
Else
txtmedSSN.Text = !Soc_Sec
End If
If IsNull(!MI_Name) Then
txtMI.Text = ""
Else
txtMI.Text = !MI_Name
End If
End With
-
Try this
Code:
With rsPI
txtFSN.Text = "" & !FSN
txtFirst.Text = "" & !First_Name
txtLast.Text = "" & !Last_Name
medSSN.Text = "" & !Soc_Sec
txtMI.Text = "" & !MI_Name
End With