Listbox selection to find records in table

  • Thread starter Thread starter Mario M
  • Start date Start date
M

Mario M

Hi all ,

I have a form with a "TABLE" recordsource.
On this form i have a listbox with property multiselect on extended.

What i'd like to do is :
I'd like to find the record(s) in the table for the selected item(s) in the
listbox , and modify the records where needed.

Can someone help me with this.

==> If my question is not clear , pls tell me.

Many thanks
Mario M
 
Use the form's AfterUpdate() event.

Private Sub Form_AfterUpdate()
Dim var as Variant
Dim ctl as ListBox
Dim str as String
Set ctl = Screen.CurrentControl
For Each var In ctl.ItemsSelected
'str = str & "," & ctl.ItemData(var)
'str = str & ",'" & ctl.ItemData(var) & "'"
'str = str & ",#" & ctl.ItemData(var) & "#"
Next var
str = Mid(str,2)
Me.Filter = "[Item] In(" & str & ")"
Me.FilterOn = True
End Sub

Uncomment one of the 3 lines depending on the datatype of
[Item]. The first is for numeric, 2nd is for text, 3rd is
for date. Hope it helps. Good luck.
 
Elwin

Many thanks for responding.
This will help
Thanks again

Mario

Elwin said:
Use the form's AfterUpdate() event.

Private Sub Form_AfterUpdate()
Dim var as Variant
Dim ctl as ListBox
Dim str as String
Set ctl = Screen.CurrentControl
For Each var In ctl.ItemsSelected
'str = str & "," & ctl.ItemData(var)
'str = str & ",'" & ctl.ItemData(var) & "'"
'str = str & ",#" & ctl.ItemData(var) & "#"
Next var
str = Mid(str,2)
Me.Filter = "[Item] In(" & str & ")"
Me.FilterOn = True
End Sub

Uncomment one of the 3 lines depending on the datatype of
[Item]. The first is for numeric, 2nd is for text, 3rd is
for date. Hope it helps. Good luck.
-----Original Message-----
Hi all ,

I have a form with a "TABLE" recordsource.
On this form i have a listbox with property multiselect on extended.

What i'd like to do is :
I'd like to find the record(s) in the table for the selected item(s) in the
listbox , and modify the records where needed.

Can someone help me with this.

==> If my question is not clear , pls tell me.

Many thanks
Mario M


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top