Modifying List Box (1 Viewer)

Kundan

Registered User.
Local time
Today, 13:02
Joined
Mar 23, 2019
Messages
118
In the attached DB I want to make the following changes:
• I want the list box (which displays possible matches) to include all the fields of tblPeople
• I want more than one item to be selected (and transferred to form frmProfile) in the listbox (which displays possible matches).
Please guide me.
 

Attachments

  • Adv_Search.zip
    92.9 KB · Views: 50

June7

AWF VIP
Local time
Today, 12:02
Joined
Mar 9, 2014
Messages
5,423
If you want to include all fields of tblPeople then that is simple to do, just as was done for FName, LName, DOB. Fix listbox ColumnCount and ColumnWidths properties.

Why not make listbox RowSourceType a Table/Query instead of ValueList? Then set the RowSource property with SQL statement instead of looping recordset and building ValueList, just use that same query as RowSource. Code reduces to:
Code:
Public Sub sFillList(strIDs As Variant, Fn As String, Ln As String)
    If Not IsNull(strIDs) Then
        DoCmd.OpenForm "frmMatches"
        Forms("frmMatches").TFN = Fn
        Forms("frmMatches").TLN = Ln
        Forms("frmMatches").SearchLabel.Caption = "Search Results for "" " & (Fn + " ") & (Ln) & " """
        Forms("frmMatches").lstMatches.RowSource = "select * from  tblPeople where PartyID in (" & strIDs & ")"
    End If
End Sub
If you need to show a count, then pass that value to function.

Then if you want to multi-select items in listbox, set it for that (either Simple or Extended). Loop through selection and do what you want with each. Many examples available, here is one https://stackoverflow.com/questions...od-or-data-member-not-found/58807693#58807693. In your case, build another CSV string to use as filter criteria for form RecordSource query.
 
Last edited:

Kundan

Registered User.
Local time
Today, 13:02
Joined
Mar 23, 2019
Messages
118
Thanks. GOD BLESS YOU!!!!!!!!!
 

Users who are viewing this thread

Top Bottom