Results 1 to 5 of 5
  1. #1
    TomH is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2017
    Posts
    10

    Must I have a Validation Rule to create Validation Text?

    Greetings all. I'm a new member here and since I'm a total


    novice at Microsoft Access, you will probably see a lot of
    questions from me. In any event, thank you so very much
    for this site.

    Many years ago I had just enough knowledge of Foxpro v2.6a
    for DOS to be dangerous. I'm now attempting to make the
    transition to a Windows database management system.
    My first choice was to stay with Foxpro, as in Visual Foxpro v9.
    However, the lack of available learning resources hampered that
    idea. So, here I am with Access 2016 running on a Windows 7
    64 bit system, trying to get a handle on the program.

    I'm the records keeper for my graduating high school class and
    my Foxpro DOS program has performed well all these years, even
    under the Windows 7-64 bit OS. When I need to turn it over to
    someone else, I would like it to be a turn-key windows program
    and not a kludged-up arrangement to run DOS in the Windows environment.

    My first of I'm sure many questions, regards the default Access Validation Text.
    Is there anyway to substitute my text, for the default, sometimes
    cryptic text, without establishing a Validation Rule?
    I, seemingly, do not need a Validation Rule because the Input Mask
    does its job as intended. The Input Mask is: !\(000") "000\-0000;;_
    However, if the data fails to meet the Mask, the somewhat cryptic error
    message is displayed.

    If it is not possible to substitute my text without a Validation Rule, could
    someone please help me with a Validation Rule for a format of: (123) 456-7890,
    or at least point me to some book or video that explains it. They never seem
    to use a phone number field when explaining data validation in any of the
    books or videos I've encountered.

    I hope I've explained the problem in an understandable way.

    Thanks for reading this,

    TomH

    PS If this is in the wrong section, or I've violated any forum policies, please let me know.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Bing: access capture input mask error message

    https://access-programmers.co.uk/for...d.php?t=163633

    Code:
    Private Sub Form_Error(DataErr As Integer, Response As Integer)
        If DataErr = 2279 Then
            Beep
            MsgBox "Your message goes here", vbCritical, "Idiot Proofing"
            Response = acDataErrContinue 'this stops the access message
        End If
    End Sub
    Last edited by June7; 12-05-2017 at 03:17 PM.
    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
    TomH is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2017
    Posts
    10
    June7,

    Thank you for the prompt reply with exactly what I was looking for. You give me too much credit for my Access knowledge though, as I had no idea where to put your code.
    With a little searching, I found, and followed, this procedure:

    "Open the Form in Design View
    On the Menu Bar Click View ==> Properties
    Click the Event Tab
    Select the OnError Event
    Click on the ... button
    Select Code Builder ==> OK
    Your Error() Event should now be visible - Paste or write the code here"

    Since it appears to be working, I'm guessing I placed your code in the correct spot. I see a possible problem with this resolution, although it will not affect this form as I have only two (2) phone fields utilizing an Input Mask. It appears this code will intercept ANY Input Mask violation on the form and would display the "Enter correct phone number" message. Is there a way to enter the code at the field level and/or the form level, or is that not even a logical question?

    Again, thank you for your time and expertise, they are greatly appreciated.

    TomH

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Could have a generic message: "The value you entered is not correct for this field."

    Otherwise, conditional code to trigger tailored message. Perhaps (not tested):
    Code:
    If DataErr = 2279 Then
        Beep
        Select Case = Me.ActiveControl.Name
            Case "Phone1", "Phone2"
                MsgBox "Enter correct phone number"
            Case Else
                MsgBox "This message"
         End Select
         Response = acDataErrContinue 'this stops the access message
    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.

  5. #5
    TomH is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2017
    Posts
    10
    Thanks, I'll play around with that. It looks promising.

    Take care,

    TomH

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

Similar Threads

  1. Replies: 11
    Last Post: 07-07-2016, 06:21 PM
  2. Puzzling validation rule for text only
    By bwelton in forum Database Design
    Replies: 4
    Last Post: 12-03-2015, 09:08 AM
  3. Replies: 2
    Last Post: 06-16-2015, 03:52 AM
  4. Replies: 2
    Last Post: 12-27-2013, 07:32 AM
  5. Validation rule for a text field
    By wasim_sono in forum Forms
    Replies: 4
    Last Post: 03-14-2006, 11:39 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