Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004
    Harrisburg, PA

    Unanswered: Saving info in a multi-select listbox

    Help! Can anyone tell me how to save multiple entries in a listbox? I currently have a fairly simple form that is connected to two tables via a query - one table that stores the entries in the listbox and another table that stores everything else on the form. The primary key is an Autonumber field that is created by the main table and I was going to have the listbox table capture this Autonumber in a text field, which will enable the db to identify which listbox entries belong to which record in the main table........Any help would be greatly appriciated.


  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    You have to iterate through the listbox to determine if each item is selected, then take action based on that. You can find an example on how to do this in the access help files under "listbox object" -> properties -> selected
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jul 2004
    Harrisburg, PA
    Thanks, Teddy........I've found the solution to my first situation, but now I need to do the reverse - can anyone tell me how to highlight the items in the listbox based on what values are in the table? Here is the coding that fixed my first problem (if that helps):

    Dim MyDB As DAO.Database
    Dim frm As Form, ctl As Control
    Dim varItm As Variant, i As Integer
    Dim rstSelectedCSR As DAO.Recordset

    Set MyDB = CurrentDb()
    Set rstSelectedCSR = MyDB.OpenRecordset("tbl_CSRRefNumTable", DB_OPEN_DYNASET)
    Set frm = Forms!frm_RETPolicies
    Set ctl = frm!lstCSRREFFrom
    For Each varItm In ctl.ItemsSelected
    rstSelectedCSR!CSRRef_EntryNum = ctl.Column(0, varItm)
    rstSelectedCSR!CSRRef_AutoEntryNum = txtEntryNo.Value
    Next varItm

    For i = 0 To lstCSRREFFrom.ListCount - 1 'clears the selection
    lstCSRREFFrom.Selected(i) = False
    Next i


Posting Permissions

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