Question : Display subform data linked to multiple data on main form

Hey there,
I am trying to get my subform to display its data based on a field on the mainform which is a list box where my users can select one OR more values.  My subform, of course, works just fine if only one item in the list box is selected, but as soon as you select more than one (via the CTRL key), the subform will not display.

Note:  I am storing the values from the list box into a field on the main form and the result is multiple values separated by a comma.

Any help in figuring this out is great appreciated - ~Paula

Answer : Display subform data linked to multiple data on main form

along the line that MelindaJohnson post,,

the subform does not have a rowsource property, it use a record source.
in the afterupdate event of the listbox, create a sring of selected items

private sub list0_afterUpdate()
dim j, sLst
with me.list0
      if .itemsselected.count >0 then
        for each j in .itemsselected
            sLst=sLst & "," & chr(39) & .itemdata(j) & chr(39)
        next
     end if
     sLst=mid(slst,2)
end with

me.subformname.form.recordsource="select * from tableName where [fieldname] in (" & slst & ")"


that will vary depending on the data type of the bound column of the listbox

can you post the rowsource of the listbox

also note that you have to remove the link master/child fields setting of the subform






Random Solutions  
 
programming4us programming4us