Multi select Picklist selection to be used for Recordset

M

mickarlsmith

How would i use a Where Condition to get a multi select pick list to
populate a record set?
 
M

micarl

I'm not trying to filter a form, as such. I'm trying to populate a
Recordset so that i can use values from that record set to send Mail
Merge letters to.

The example given the form uses the query to filter this data.

How would i populate a recordset with selections made from a Multi
select Listbox, also, not a single select list box like in your
example.
 
M

mickarlsmith

that example let's the report filter the query. I'm wanting to poulate
a recordset with selections made in a Multiselect Listbox so that i
can select several departments to send Mail Merge letters to.
The example also only shows single select list boxes. I could do that,
no problems, but i'm stuck trying to populate a record set with multi
select listbox selections.
 
L

Larry Daugherty

You need to iterate the index of the multi-select listbox and test
whether each value *IsSelected*.

HTH
 
K

Ken Snell \(MVP\)

The sample database shows you how to walk through the selections made in the
listbox and get the individual items. I was assuming that you could adapt
that snippet of code for your use -- your post suggested to me that you have
experience with VBA.

Use that part of the code that walks the listbox's selections, and add steps
to write each value into a recordset during each 'loop' through the listbox.

If you have no success with it, post back.
 
K

Ken Snell \(MVP\)

My memory was bad -- you're right, the sample only shows a "simple"
selection list box. I'll need to improve that later.

Code would be this, assuming that you have a recordset already created and
opened:

Dim varItemSel As Variant
For Each varItemSel In Me.ListBoxName.ItemsSelected
rstRecordsetName.Edit
rstRecordsetName!FieldName.Value = _
Me.ListBoxName.ItemData(varItemSel)
rstRecordsetName.Update
Next varItemSel
 
K

Ken Snell \(MVP\)

Actually, no, my memory was not bad. I am using a Simple multiselect list
box in that example database.
 
M

mickarlsmith

I thought all the Databases would be the same, so only checked the
access 2000 database. The 97 database appears to be the only one to
have a multi select listbox. Thanks i will investigate.
 
L

Larry Daugherty

Doug,

You're right, of course. Thanks for catching that and steering folks
in the correct direction.
 

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

Top