Simple if, then problem (1 Viewer)

colinmunnelly

Registered User.
Local time
Today, 13:40
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
 

jca

I need to think it over !
Local time
Today, 08:40
Joined
Aug 1, 2001
Messages
42
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
 

colinmunnelly

Registered User.
Local time
Today, 13:40
Joined
Feb 26, 2002
Messages
89
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"
 

jca

I need to think it over !
Local time
Today, 08:40
Joined
Aug 1, 2001
Messages
42
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.
 

jca

I need to think it over !
Local time
Today, 08:40
Joined
Aug 1, 2001
Messages
42
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.
 

colinmunnelly

Registered User.
Local time
Today, 13:40
Joined
Feb 26, 2002
Messages
89
thanks alot. I understand now. Learn loads on here!! Thanks again
 

Users who are viewing this thread

Top Bottom