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!

Checking an unbound text box for a Null/Empty value.its driving me mad

Status
Not open for further replies.

LDG1234

Programmer
Jun 26, 2001
120
0
0
GB
Hi Guyz

Can anyone help me out. For some unknown reason I cannot execute an If statement which should check a field to see if it is empty.

I have a 3 Unbound Text Boxes, TxtStartDate , TxtEndDate, TxtTitle.

They are where the operator put the parameters for a bunch of reports.

The operator clicks on the Print Report Button and the following code should run.


If (Len(TxtEndDate) = 0) Or (Len(Me.TxtStartDate) = 0) Or (Len(Me.TxtTitle) = 0)

MsgBox "You must enter a Start Date, End Date and Title for the Reports", vbCritical

Else
If Me.SCARFOutstanding = -1 Then
DoCmd.OpenReport "SCARFS Outstanding"
End If
End If


This won't work. I have also tried Me.TxtStartDate = "" and
Nz(Me.TxtStartDate, "") = ""

These won't work either. I don't know why but it seems so simple to me. I've done this loads of times before.



Lloyd Gozzett
Process Developer
 
Hey Lloyd,

I have been fighting this same problem for a week. Like you the same things that was working for me before were not working this time, so let us all know how it goes for you. I know for me IsNull didn't work either. Your code Nz(Me.txtStartDate,"")="" should have taken care of Null. Also, if you think you've got it working go in and test by adding a value to one of the fields then go back into it and delete the value and try to close and see what your code does.

I can tell you two things that has worked for me. One is I had to create a varible and make the value of the variable = the value of the unbound text box, then check the varible for Null. The other is a piece of code that someone shared with me: Trim(Nz(varStartDate,"")) = ""

Hope you find this helpful,
Shane
 
Thanks for the help guys.

I have it working now using the Nz code. Still baffled to know why it doesn;t like the other ways though. They've worked before...another nice little Microsoft Quirk!
Lloyd Gozzett
Process Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top