Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't catch NULL. 2

Status
Not open for further replies.

craiogram

MIS
Feb 20, 2004
126
0
0
US
Please help me understand. This was working for me a little while ago. Now if I leave txtCpyQuote blank it comes thru as null but my if statement won't catch it. I stepped thru it with the locals window and is shows a value of null but still doesn't get caught. Thank you.

On Error GoTo ErrCpyQuote
Dim var1, var2, quoteHld As Variant
Dim AutoNumHld1, AutoNumHld2 As Integer

'Variables for the DoCmd.OpenForm because without it you get the pop-up box
var1 = Me.txtCpyQuote.Value
var2 = "Quote ="

If Me.txtCpyQuote.Value = "" Or Me.txtCpyQuote.Value = Null Then 'This is to catch when the TextBox is left blank.
MsgBox "Please enter a Quote Number to find and copy."
GoTo txtEmpty
End If
 
Try this (works in VB)
Code:
If Me.txtCpyQuote.Value = "" Or ISNULL(Me.txtCpyQuote.Value) Then 'This is to catch when the TextBox is left blank.
 
Hello SonOfEmidec1100

A star to you! I've been puzzling as to why my If statement wouldn't pick up a textbox null. I see that I need .Value.

Thanks
Dave
 
This is why I use wherever possible -

If Len(Nz(MyTextBox)) = 0 Then

to handle the same issue.
 
To handle Null, Empty and Blank all in one:
If Trim(myTextBox & "") = "" Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 

Hello payback and PHV (aka TipMaster!)

Thanks for your tips. I've solved my immediate problem but can see that I've got homework to do when I've a bit more time.

Cheers
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top