Results 1 to 3 of 3

Thread: Prevent new data if record is in a list box

  1. #1
    Join Date
    Feb 2010
    Posts
    3

    Prevent new data if record is in a list box

    On one of my form I have a list box that is filtered, is it possible to prevent new record from being added if the record would create a duplicate in the list box? one option is to index this field however this then applies to the entire database. I would like it to be for the filtered data only.

  2. #2
    Join Date
    Mar 2006
    Location
    Oklahoma City, OK
    Posts
    184
    Quote Originally Posted by gravedigger View Post
    On one of my form I have a list box that is filtered, is it possible to prevent new record from being added if the record would create a duplicate in the list box? one option is to index this field however this then applies to the entire database. I would like it to be for the filtered data only.
    I would use the Form's Before Update event to test to see if the record already exists in the list box.

    You could also use the after update event of the control that would have the data that would cause the duplicate to run the validation code to look for a duplicate.

    I would normally open a recordset using the same criteria that filters the listbox plus the data that you want to see if is a duplicate. If the recordset has a record, then it would create a duplicate.
    Boyd Trimmell aka HiTech Coach
    Microsoft MVP - Access Expert
    [SIGPIC][/SIGPIC]
    Office Programming 25+ years as a Software Developer specializing in:
    Business Process Management
    Accounting/Inventory Control
    Customer Relations Management (CRM)
    Electronic Data Interchange (EDI)

  3. #3
    Join Date
    Feb 2010
    Posts
    3
    What I ended up doing was make an index using the table foreign key and the field I didn't want the duplicate in.


    Quote Originally Posted by HiTechCoach View Post
    I would use the Form's Before Update event to test to see if the record already exists in the list box.

    You could also use the after update event of the control that would have the data that would cause the duplicate to run the validation code to look for a duplicate.

    I would normally open a recordset using the same criteria that filters the listbox plus the data that you want to see if is a duplicate. If the recordset has a record, then it would create a duplicate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •