Results 1 to 7 of 7
  1. #1
    reyn240 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    2

    if then

    I am using the following code to get a mesagebox to open up.
    Code:
    If TC >= ([Forms]![frmpowderedwhites]![ColiformUpper]) Then
     '   MsgBox "COLIFORM TEST HAS NOT MET THE REQUIRED SPECIFICATIONS. PLEASE RETEST TO INSURE THE RESULTS ARE ACCURATE", vbOKOnly
    . the problem I am having is that no matter what value I enter into the field the message box opens up. I only want it to open up if the value is greater that the ColiFormUpper field. Any suggestions would be greatly appreciated.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Show us more code.
    What is TC?
    What is ColiFormUpper (number, text??)
    The ' at the beginning of the msgbox line makes it a comment???

  3. #3
    reyn240 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    2
    The TC is the name of the field where the value us entered into. ColiFormUpper is the field containing the value that TC is compared to. Both are number fields. The ' is not in my code. I copied the code I put in the post from my documentation.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Try putting this before your IF

    Debug.print "TC is: " & TC & " and ColiFormUpper is : " & Forms!frmpowderedwhites!ColiformUpper

    Then see what the values are in your immediate window.

  5. #5
    qa12dx is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    india
    Posts
    112
    Quote Originally Posted by reyn240 View Post
    Code:
    If TC >= ([Forms]![frmpowderedwhites]![ColiformUpper])...
    . I only want it to open up if the value is greater that the ColiFormUpper field. Any suggestions would be greatly appreciated.
    right now it is greater than or equal to in ur code. i tried one with a date field, works for me;

    If (Forms!Form1!tc > Date) Then
    Beep
    MsgBox "blah bhal", vbInformation, "gusta good"
    End If

  6. #6
    Amerlitong is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Feb 2013
    Posts
    10
    Quote Originally Posted by reyn240 View Post
    The TC is the name of the field where the value us entered into. ColiFormUpper is the field containing the value that TC is compared to. Both are number fields. The ' is not in my code. I copied the code I put in the post from my documentation.
    try to use ME. object reference(if that field its in the same form)---> ME.TC as u said this is a field...
    when i see the code im thinking TC is a variable...

    make it habit to use ME reference

    Cheers

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Is TC a Variable, as has been suggested, or a Control on the currently opened Form?

    Is ColiformUpper a Control on the same Form?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums