How to prevent selecting duplicate records in a listbox.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fatou

    How to prevent selecting duplicate records in a listbox.

    I have a listbox where the user selects only one value at a time. The
    problem is that once the user selects the value and the record is
    updated in the table, they can reselect the same value again. I do
    not want this to happen. Your input is greatly appreciated.
  • HS Hartkamp

    #2
    Re: How to prevent selecting duplicate records in a listbox.


    Would it be possible to determine from the database if the record has been
    updated already ? If so, it would be possible to use the AfterUpdate event.
    In there you could change the recordsource of the list box so that the
    record is excluded that has been changed already.

    If not and you really want to do this, you could add a flag to the table. On
    opening the form, all flags are cleared. On changing, the flag is set, and
    the recordset is changed.
    Alternatively, you could add a selection table that is emptied on opening
    the form, and is filled with all the record ID's of the changed records (one
    ID added after each record update). Change the list box recordset to SELECT
    [x] FROM [y] WHERE [Id] NOT IN (Select [id] From [SelectionTable]).

    Just play around a bit..

    Bas Hartkamp.

    ** Computers can do ANYTHING It's just a matter of programmers' persistence
    **


    Fatou <fa2njie@yahoo. com> schreef in berichtnieuws
    a29e4f02.030829 1220.35396f37@p osting.google.c om...[color=blue]
    > I have a listbox where the user selects only one value at a time. The
    > problem is that once the user selects the value and the record is
    > updated in the table, they can reselect the same value again. I do
    > not want this to happen. Your input is greatly appreciated.[/color]


    Comment

    • Larry Linson

      #3
      Re: How to prevent selecting duplicate records in a listbox.

      You will need some method to determine which records have been updated
      (within the time limits you decide... perhaps "this execution of the
      database") and select only those which have not been for your listbox.
      Obviously, this will require a requery of the list box after you
      update.

      Perhaps an Updated field in the records, set when you update, and
      cleared when you shut down the database application would do what you
      want.

      Larry Linson
      Microsoft Access MVP

      fa2njie@yahoo.c om (Fatou) wrote in message news:<a29e4f02. 0308291220.3539 6f37@posting.go ogle.com>...[color=blue]
      > I have a listbox where the user selects only one value at a time. The
      > problem is that once the user selects the value and the record is
      > updated in the table, they can reselect the same value again. I do
      > not want this to happen. Your input is greatly appreciated.[/color]

      Comment

      Working...