Results 1 to 4 of 4
  1. #1
    Accession is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    7

    Placing Validation on Forms

    Good day everyone,



    I have never written codes in access. However, I am familiar with Visual Basic. I created this form in access for a database. I am trying to place validation on the form controls(elements).
    Example: Lets say I need a error message to display when a textbox is focused and left empty. I need to make First Name mandatory so if the user click in the text box for first name and leaves it blank and error message is display when they try to leave.

    I already have the name field required on the database but can I do this on forms? I tried writing some Visual Basic coded by opening the form and going to design view, then selecting an event but the codes I wrote does not work.

    How can I make this work?

    Thanks everyone!

    AC

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    I already have the name field required on the database but can I do this on forms
    This means that you have made the field required in the table? If this is the case, is your form bound to your table? If yes, then there is no reason to apply this type of validation as it is already set. If your form is not bound to your table, then that is a different situation and I will have to defer to my peers for that answer.

    Alan

  3. #3
    Accession is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    7
    Quote Originally Posted by alansidman View Post
    This means that you have made the field required in the table? If this is the case, is your form bound to your table? If yes, then there is no reason to apply this type of validation as it is already set. If your form is not bound to your table, then that is a different situation and I will have to defer to my peers for that answer.

    Alan
    Thanks for responding, I do have the name field required on the database however, that validation does not fire up until the user decides to submit the form. I was simply asking if there is a way to make the form require input when it loses focus, this way the user does not have to complete the entire form before realizing something is missing.


    Thanks again.

    AC

  4. #4
    stmoong is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Location
    Singapore
    Posts
    108
    You can use the LostFocus event of the control to validate the data entered. If fails, set the focus back to the control so that user can correct the data.

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

Similar Threads

  1. PLEASE HELP ME - Placing labels over an image
    By BrainKing in forum Forms
    Replies: 4
    Last Post: 10-31-2010, 01:43 PM
  2. Replies: 4
    Last Post: 04-01-2009, 08:49 PM
  3. Placing images quickly
    By marcello.dolcini in forum Import/Export Data
    Replies: 1
    Last Post: 10-20-2008, 06:05 AM
  4. VBA Opening Excel File and Placing Data in Cells
    By BobTHG in forum Programming
    Replies: 0
    Last Post: 01-13-2008, 03:01 PM
  5. Placing '0' in front of data
    By wasim_sono in forum Queries
    Replies: 2
    Last Post: 09-07-2006, 06:00 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