Listbox Question (1 Viewer)

TheSearcher

Registered User.
Local time
Today, 18:06
Joined
Jul 21, 2011
Messages
304
I have frm_NewClient which adds a new client to the database.
The controls are:
txt_Client_Id
txt_FirstName
txt_LastName
lst_Payers (This is a multiselect list box that displays different insurance carriers)

My insert query works perfectly. I am able to get the selected items from the listbox into my table.

However, I also have frm_UpdateClient which updates any client info. The controls are the same as on frm_NewClient.
My question: How do I show what payers were originally selected in my listbox? In other words, how do I show them as being selected in the listbox after my recordset returns all of the info?

Thanks in advance,
TS
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:06
Joined
May 21, 2018
Messages
8,534
Take a look at this demo. May help
 

TheSearcher

Registered User.
Local time
Today, 18:06
Joined
Jul 21, 2011
Messages
304
Brilliant! Thank you very much!
I only had to use a very small snippet of code (see below). I did have to change SelectedID to string however. Also had to comment out the Exit For statement.

Code:
'****************************
  Dim varItm As Variant
  Dim SelectedID As String
  Dim i As Integer
 
  'loop the recordset
  Do While Not rs1b.EOF
    SelectedID = rs1b("Payer")
      
    For i = 0 To (lst_Payers.ListCount - 1)
       If lst_Payers.Column(0, i) = SelectedID Then
        lst_Payers.Selected(i) = True
        'Exit For
        End If
    Next i
    rs1b.MoveNext
  Loop
'**********************************************
 

Users who are viewing this thread

Top Bottom