Link to home
Start Free TrialLog in
Avatar of MRG_AL
MRG_AL

asked on

Field = blank in Access form

This should be so simple but yet I can't get an if then statement to work in vba for an access form. I created a button called "Correct" and when it is clicked I need code to run through the data in the split form to determine if it is correct or not. I don't have an issue if it is correct but when the field is blank the code automatically returns "incorrect" unless I write the code backwards. Like
If field1 <> "" then
field2 = "Incorrect"
else
field2 = "Correct"
end if

But I want to be able to also check numerous other answers in the field so I would like something like:

If field1 = "" or field1 = "12/31/2010" then
field2 = "Correct"
else
field2 = "Incorrect"
end if

Thank you
Avatar of Runrigger
Runrigger
Flag of United Kingdom of Great Britain and Northern Ireland image

Your question isn't that clear.

Are you indicating that blank is correct sometimes?

What would be incorrect?
Avatar of MRG_AL
MRG_AL

ASKER

I'm sorry. If it is blank I do want the connecting field to return "correct
This is my exact code for command "Correct"

Do While Me.MemberID <> ""
If Me.MemberID = "1411" Then
    If Me.HealthGuidance = "12/31/2010" Or Me.HealthGuidance = "" Then
        Me.NUM3 = "Correct"
    Else
        Me.NUM3 = "Incorrect"
    End If
End If
DoCmd.GoToRecord , , acNext
Loop
ASKER CERTIFIED SOLUTION
Avatar of Runrigger
Runrigger
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MRG_AL

ASKER

Thank you!!
You are welcome