Results 1 to 4 of 4
  1. #1
    dolovenature is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    14

    Age Validation with Message Box

    Hi,
    I am absolutely novice in access, and i am entrusted with a responsibility.
    My Problem is.....
    I have a FORM(form1) related to a table(table1).
    While entering data using the FORM if the AGE field is less than 18 then a Message box would appear "Age is not valid" with only one button is the box "Ok",
    If the user click OK it will return to the FORM.
    can anybody help with the code?
    (Sorry for posting in some other threads...)
    Regards


    Saikat

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You could try the ValidationRule and ValidationText properties of textbox.
    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.

  3. #3
    Missinglinq's Avatar
    Missinglinq is online now VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Or, for a friendlier approach (the Access Gnomes can be very abrupt!)

    Code:
    Private Sub AgeField_BeforeUpdate(Cancel As Integer)
     If Me.AgeField < 18 Then
      MsgBox Me.AgeField & " Is Not Valid Age for this Field!"
      Cancel = True
      AgeField.SelStart = 0
      AgeField.SelLength = Len(Me.AgeField)
     End If
    End Sub


    Just replace AgeField with the actual name of your 'age' Control.

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

    All posts/responses based on Access 2003/2007

  4. #4
    dolovenature is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    14
    Quote Originally Posted by Missinglinq View Post
    Or, for a friendlier approach (the Access Gnomes can be very abrupt!)

    Code:
    Private Sub AgeField_BeforeUpdate(Cancel As Integer)
     If Me.AgeField < 18 Then
      MsgBox Me.AgeField & " Is Not Valid Age for this Field!"
      Cancel = True
      AgeField.SelStart = 0
      AgeField.SelLength = Len(Me.AgeField)
     End If
    End Sub


    Just replace AgeField with the actual name of your 'age' Control.

    Linq ;0)>

    Thanks a lot Missinlinq....
    And I am having another problem mentioned at the thred "Ranking Students based on Score & Location and selecting Top three..."

    would you please highlight some solution??
    Regards
    saikat
    Last edited by dolovenature; 08-26-2012 at 01:16 PM. Reason: to achieve information

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

Similar Threads

  1. POP UP Message - validation test
    By akhlaq768 in forum Forms
    Replies: 1
    Last Post: 02-22-2012, 05:03 AM
  2. validation
    By slimjen in forum Forms
    Replies: 6
    Last Post: 10-12-2011, 01:19 PM
  3. Validation Rule Help!
    By confidego in forum Access
    Replies: 8
    Last Post: 07-20-2011, 12:54 PM
  4. Data Validation using VBA
    By Cheshire101 in forum Programming
    Replies: 3
    Last Post: 05-10-2011, 08:43 AM
  5. Custom validation error message
    By snorkyller in forum Access
    Replies: 2
    Last Post: 03-21-2011, 03:40 PM

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