If reference cells are blank, how to make the results go blank

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tmdrake
    New Member
    • Mar 2013
    • 43

    #1

    If reference cells are blank, how to make the results go blank

    I have to entry boxes on a form. If the boxes are populated then this is the path that is ran:

    Code:
    If Me.PullForce.Value > 14 And Me.Nuggets.Value > 4 Then Me.Test_Results.Value = "Failed"
    If Me.PullForce.Value < 15 And Me.Nuggets.Value < 5 Then Me.Test_Results.Value = "Passed"
    If Me.PullForce.Value = "" And Me.Nuggets.Value = "" Then Me.Test_Results.Value = ""
    No how do I write it if boxes PUllforce and Nugget are blank so that the Test Results field will go blank?

    Thanks
    Last edited by zmbd; Mar 13 '13, 05:48 PM. Reason: [z{placed required code tags.}]
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    Since you haven't used code tags, I'm not sure if you have three separate lines or six separate lines. If three, then what you have should work. If six, then you End If after each If statement.

    Have you tested this? At first glance, nothings looks wrong, although if Me.PullForce and Me.Nuggets are number fields, then you should be testing for IsNull() instead of empty strings (which is what "" is). Where do you have this code? Do you get any error messages when it runs, or do you just not get the results that you expect?

    Also, please read Before Posting (VBA or SQL) Code before posting any more code. It is really important to follow these rules as it helps us read your code and see problems.

    Comment

    • tmdrake
      New Member
      • Mar 2013
      • 43

      #3
      I was able to get it to work. Thanks

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        You really should also consider using the select...case or the if...then...els eif constructs as they are a much cleaner code and ensure that only result of the condition you are testing occurs as expected.

        Comment

        Working...