Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    coding advice - preventing dupes (VBA/Access 2003)

    I have built a system that allows the user to select one or more people from a Staff list and assign them to a given class selection. The code is as attached.

    As you can see, the system exits from the sub when a duplicate entry is detected. This means any other people selected will not be added. I don't like the action of blocking all other additions just because of one dupe, but am not sure how to re-structure the code to allow the rest of the selections to process. An initial attempt to add a next varItem in the If Then test block doesn't get by the compiler. I suppose I could set a flag and run an UPDATE Sql string on dupes and the INSERT INTO otherwise, but that seems inelegant. Any ideas?

    TIA
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: coding advice - preventing dupes (VBA/Access 2003)

    Why not remove the Exit Sub line after the MsgBox?

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: coding advice - preventing dupes (VBA/Access 2

    well - that appears to be a good idea. a one-character change! I will need to change the wording on the msgbox for dupes, of course.

Posting Permissions

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