Handling NULL

battenberg

Burning candles both ends
Local time
Today, 00:31
Joined
Sep 25, 2006
Messages
118
Hi

I have a simple form with a single unbound text box which captures a 'user note' string and theoreticaly could be null when the command button 'on click' is fired

i have put the code:
Code:
If Me.Text1 = Null Then GoTo cont:
'
'
'
' more code here!
'
'
'
cont:
MsgBox "No User Note Entered! Click close to exit", vbExclamation

End Sub

this code seems to be skipped when the event is fired.... can anyone help me with the correct syntax???

thanks....
 
if isnull(Me.Text1) then ...

probably better to check for empty strings as well though

if Me.Text1 & "" = "" then ...


HTH

Peter
 
Thank you...
 
Even easier is to use the Null Zero function.

If Nz(Me.Text1,"")="" Then

The Nz function is very handy. It works like this:

Nz([Control_To_Check_For_Null_Value],[Value_To_Assign_If_Null_Is_True])

~Moniker
 

Users who are viewing this thread

Back
Top Bottom