Results 1 to 10 of 10
  1. #1
    FormerJarHead is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    52

    Message Box based on field entry

    Hi all -



    I have a form field I'm trying to add a message box to. When the user enters an amount greater than 1, I would like the message to notify the user. If no entry is made, no message is displayed. What I thought was relatively simple has sucked up about 3 hours so far. If I had hair, I'd pull it out! Any help will be greatly appreciated.

    Thank you

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I think you want to use the "AfterUpdate" event of the field to return your Message Box. Just incorporate your logic/message box into that, and it will automatically run upon an entry being made to that field.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    SEE ALSO: the text box property of VALIDATION RULE, and VALIDATION TEXT

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,631
    I agree with ranman. This looks ideal for textbox ValidationRule property. Expression could be:

    <=1 Or Is Null

    ValidationText property could have:

    "Enter value less than or equal to 1 or ESC to cancel entry."
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Yep, forgot about Validation on Forms.
    Certainly easier than using VBA!

  6. #6
    FormerJarHead is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    52
    Thanks to all. Simple solution to my complex problem. What happens though with validation is it will not allow the user to chose either okay or cancel as a message box would. The user then has to remove their entry completely before proceeding through the remainder of the form. I basically want them to be aware of the entry and the field they are using, not completely prevent them from entering a value

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,631
    If you want to permit the entry even if it violates some threshold then ValidationRule is not appropriate. Use the VBA.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    FormerJarHead is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    52
    I know how to create the message box but not quite clear how I would write the code to do what I'm asking. Can you offer any assistance?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,631
    Code in the control's BeforeUpdate or AfterUpdate.

    Do you just want to notify the user? Use AfterUpdate:

    MsgBox "You entered value " & Me.controlname & " which exceeds the threshold of 1."

    Or do you want to give them choices? Use BeforeUpdate:

    If MsgBox("You entered value " & Me.controlname & " which exceeds the threshold of 1. Do you want to keep this value?", vbYesNo) = vbNo Then
    Cancel = True
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    FormerJarHead is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    52

    Thumbs up

    Thanks June! That did it!

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

Similar Threads

  1. Limit data entry based on another field
    By chemengr in forum Forms
    Replies: 5
    Last Post: 01-02-2014, 01:21 PM
  2. Replies: 1
    Last Post: 12-05-2013, 01:15 PM
  3. Replies: 2
    Last Post: 12-04-2013, 05:38 PM
  4. Replies: 10
    Last Post: 10-31-2011, 05:18 PM
  5. Replies: 4
    Last Post: 04-18-2011, 07:18 AM

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