Results 1 to 3 of 3
  1. #1
    Phillsoft is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2011
    Posts
    2

    Checking if data already exist in a Table

    Hi Guys

    I have a form with a number of fields that includes Learner Name, Surname, ID Type, IDNo just to mention a few. IDNo is a primary key. I would want a simple VBA code that can validate if the IDNo already exist in the table the moment it (IDNo) loses its focus when a user is entering data. Currently the form will only pop up a message when you have finished populating it since it is a primary key and its not user friendly. Can someone help


    Thanks

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    To see if IDNo already exists in MyTable you could use a
    If DCount ( expression) > 0

    see http://www.techonthenet.com/access/f...ain/dcount.php

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if the record already exists are your data entry people supposed to update the existing record?

    If so why not perform a search first (first field is an unbound text box) and if the person exists populate your form, if they don't then take them to a new record and populate the ID field for them?

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

Similar Threads

  1. Checking if data already exist in a Table
    By Phillsoft in forum Forms
    Replies: 1
    Last Post: 08-04-2011, 08:03 AM
  2. Checking a table for changes
    By Rando in forum Queries
    Replies: 2
    Last Post: 10-07-2010, 09:25 AM
  3. If value already exist or not in the table
    By dada in forum Programming
    Replies: 3
    Last Post: 08-19-2010, 01:57 AM
  4. Checking for data in table
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 07-27-2010, 01:32 PM
  5. Check if value exist in a table
    By Lucas83 in forum Programming
    Replies: 2
    Last Post: 06-02-2010, 11:42 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