Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Field = blank in Access form

Posted on 2011-02-21
5
345 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:MRG_AL
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:Runrigger
ID: 34946820
Your question isn't that clear.

Are you indicating that blank is correct sometimes?

What would be incorrect?
0
 

Author Comment

by:MRG_AL
ID: 34946951
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
0
 
LVL 11

Accepted Solution

by:
Runrigger earned 500 total points
ID: 34947014
Have you tried

If IsNull() or IsEmpty() instead of =""
0
 

Author Closing Comment

by:MRG_AL
ID: 34947120
Thank you!!
0
 
LVL 11

Expert Comment

by:Runrigger
ID: 34947129
You are welcome
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question