Handling NULL (1 Viewer)

battenberg

Burning candles both ends
Local time
Today, 12:04
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....
 

Bat17

Registered User.
Local time
Today, 12:04
Joined
Sep 24, 2004
Messages
1,687
if isnull(Me.Text1) then ...

probably better to check for empty strings as well though

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


HTH

Peter
 

battenberg

Burning candles both ends
Local time
Today, 12:04
Joined
Sep 25, 2006
Messages
118
Thank you...
 

Moniker

VBA Pro
Local time
Today, 06:04
Joined
Dec 21, 2006
Messages
1,567
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

Top Bottom