Simple if, then problem

colinmunnelly

Registered User.
Local time
Today, 00:31
Joined
Feb 26, 2002
Messages
89
I am trying to do a nvery simple if, then statement but it doesn't seem to be working as it should. I know the solution must be really simple. Anyone shine some light.

Private Sub Form_AfterUpdate()
If text69 = "" Then
MsgBox ("no impact")
Else
'DoCmd.OpenForm "notice_input_form", acNormal
End If
End Sub
 
You have two problem in your code
First:
Code:
MsgBox ("no impact")
Should be:
Code:
MsgBox "no impact"
if you don't want to handle the return value of MsgBox

Second:
Code:
If text69 = "" Then
text69 doesn't refer to a field on your form like that
It should be something like this:
Code:
If me.text69 = "" Then

So everything should look like this:
Code:
Private Sub Form_AfterUpdate()
If me.text69 = "" Then
    MsgBox "no impact"
Else
    'DoCmd.OpenForm "notice_input_form", acNormal
End If
End Sub
 
Thanks for your reply. Still a problem though. If text69 is null the message box still does not appear. It opens the form "notice_input_form"
 
You could change it for:
Code:
If (trim(me.text69) = "") or isNull(me.text69) Then
This way, your message box will appear if the textbox contain nothing of is fill with blank.
 
If your talking about my original code, it wasn't always working because I was comparing text69 with "" and a Null value isn't equal to "" even if it looks the same in the field.

You should always use the function IsNull to check for a Null in a field and Trim() to check if your field is fill only with blank.

Hope I'm clear enough.
 

Users who are viewing this thread

Back
Top Bottom