Have an issue with code checking for Null data.

Jon123

Registered User.
Local time
Yesterday, 21:33
Joined
Aug 29, 2003
Messages
668
So on a command button I have this code in the OnClick event
When I click the button it will ask me to enter the name if blank but if I enter
something in that field and then delete the data is bypasses this. Does the same the the reason field, Why?
jon



{CODE}
If IsNull(Me.CE) Then
MsgBox "Please enter your name"
Me.CE.SetFocus
Exit Sub
Else
End If
If IsNull(Me.reason) Then
MsgBox "Please enter the reason for the rework"
Me.reason.SetFocus
Exit Sub
Else
End If
DoCmd.close acForm, "Frm-Plus"
{END}
 
because if you enter some data and then delete it , it leaves a zero length string rather than a null - use
Code:
If nz(Me.CE)<>""
And the code tags can be found on the advanced editor (the # button)- when you use them, the formating is preserved - trying to read as you have posted is difficult

Code:
If something then
    do something
end if
rather than

If something then
do something
end if
 

Users who are viewing this thread

Back
Top Bottom