opposite of Nul

lead 27

Registered User.
Local time
Today, 15:00
Joined
Mar 24, 2007
Messages
147
Hi

I am just wondering if you want to say in code that the field is empty you use "Nul" however what if you want to say that the field has text in it, is it just Nul=false or is there a better way?

thanks
 
What are you trying to do?

Like an if statement you could do:

If Not IsNull(textfield) Then

Do This Stuff

Else

Do Other Stuff

End If
 
Thanks for the quick reply.

I have demand info on my DB and I am trying to add code in the close form event so that if the user has entered a date but no Qty (believe me it happens, lol) a msgbox appears telling them to enter a Qty and the form will not close.
 
Do you want the date field checked before the qty field? Or vice versa?
 
Last edited:
Hi

I want the date field checked, if there is a date entered I need there to be a qty in the qty field if not I want a txt box to say please enter a qty, the qty field to go yellow and the form to stay open.
If there is a date and there is a qty I just want the form to close and if there is neither i want the form to close

I have come up with this so far:
If Not IsNull(Me.DATE1) and me.qty1="0" Then
MsgBox "Please enter a Qty"
Me.QTY1.BackColor = 8454143
Else
Me.QTY1.BackColor = 16777215
DoCmd.Close
End If

This works in a way, if there is a date entered the qty field will go yellow and the msgbox appears and if there is no date entered then the form closes, however the qty box is not checked so it doesnt matter what is in there

Any ideas
 
Ok got it to work using:
If Not IsNull(Me.DATE1) And IsNull(Me.QTY1) Then
MsgBox "Please enter a Qty"
Me.QTY1.BackColor = 8454143
Else
Me.QTY1.BackColor = 16777215
DoCmd.Close
End If

If anyone thinks of a better way please let me know

Thanks for your help
 
Ok this code works great however i have noticed something. I have the code on a close button however there are alot of ways to get around entering the data e.g. they can move to a different record etc.

Is there a better place to enter the code so that if they try and close the form or move records the code becomes active without putting the code onto every applicable button?

Thanks
 
Use a "before update" event for the form, which has the ability to cancel the update.
 

Users who are viewing this thread

Back
Top Bottom