Bretona10 said:
Upon closer look the main and subform are a one to many relationship.
Linked
via the CNUM field, so the main form is not unbound. This changes things a
bit. When showing all the subform records if the user applies a filter by
selection in the subform, thats the records I want to print, not All the
records that are linked. Make better sense now? Sorry for the confusion.
If the listbox is not multi-select, and the filtering is based only on "one"
value
selected in the listbox, then you should be able to do
the following:
dim strWhere as string
strWhere = "(cnum = " & me.lstBox & ")"
' now add any fitlering of the sub-form by user
if me.Mysubform.Form.Filter <> "" then
strWhere = strWhere & " and " & me.MySubForm.Form.Filter
end if
docmd.OpenReport "reprotname",acViewPreview,,strWhere
Of course, if the listbox is multi-select, then again you left out a another
big detail, and the above code would have to be changed further....
Also, if cnum is a text field, then you have add some single quotes as:
strWhere = "(cnum = '" & me.lstBox & "')"
the above assumes the button to print the report is in the main form, not
the sub-form....