0
votes

Find my vba

Private Sub Search_Click()

Dim VarItem As Variant

Dim Strsearch As String Dim Sql As String Dim ctrl As Control

Set ctrl = Me.LbobDriveType

If ctrl.ItemsSelected.Count > 0 Then

For Each VerItem In ctrl.ItemsSelected

Strsearch = Strsearch & ctrl.Column(VarItem)

Next VerItem

MsgBox (Strsearch)

Sql = "SELECT Database.[Record _ID], Database.PhysicalVIN, Database.LogicalVIN, Database.VERSION, Database.BODY_STYLE, Database.ENGINE_TYPES, Database.BODY_EXTERIOR_COLOR, Database.INDIA_OR_EXPORT, Database.DRIVE_TYPES, Database.TRANSMISSION_TYPES, Database.FUEL_TYPE, Database.MARKET, Database.MARKET_CATEGORY " _ & "FROM [Database] where DRIVE_TYPES in('" & Strsearch & "')"

MsgBox (Sql)

   End If

Me.SbfRecord.Form.RecordSource = Sql Me.SbfRecord.Form.Requery

end sub

enter image description here

enter image description here

1
Fix formatting.Bsquare ℬℬ
What exactly is your problem/question? BTW: You're missing an End If somewhere...Unhandled Exception
I am having listbox in access Form where I have put two value " LHD"."RHD". I have chosen list type - simple for multi select. Duplicate value is getting selected after selecting both the Values. like RHDRHD or LHDLHD. .Mrityunjay Sharma

1 Answers

0
votes

I expect you want the two marked entries of the listbox to be displayed in the message box instead of twice the first one?

If so, the code should work well except of the fact that there is a typo (VarItem vs VerItem) and an End If missing.

So I think your problem could be that there is more than one column defined in the listbox? Maybe the first column is hidden and contains RHD for all rows?