validation rules- access front-end for mysql

Posted on 2008-11-17
Last Modified: 2013-11-27
Would anyone have any examples of creating validation rules for an MS Access front-end to a MySql database? This would be for data entry in the front-end's datasheet view.

Question by:montarch
    LVL 84

    Accepted Solution

    By "validation rules", you mean at the Interface level? Are you using bound forms? If you are, then typically you'd validate data in the Form's Before Update event:

    Sub Form_BeforeUpdate(Cancel As Integer)
      If Len(Me.SomeTextbox)>5 Then
        "You must enter 5 or less characters"
        Cancel = True
        Exit Sub
      End If
      If Me.SomeOtherTextbox >10 Then
        Msgbox "You cannot enter a number greater than 10"
        Cancel = True
        Exit Sub
      End If
    End Sub

    If, however, you're allowing users to enter data directly in the tables, then you'd have to add constraints and such at the server.

    Author Comment

    We're not using forms. Users enter data directly into the tables. Would you have an example of or reference to adding constraints at the server?

    Thanks for your time.

    Author Closing Comment

    Actually, I think that I'll create forms with a tabular layout and use your suggestion.

    Thanks for your help.


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Creating and Managing Databases with phpMyAdmin in cPanel.
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now