Repost: Filtering Subform from a Form

M

Matt Weyland

I am reposting this as the solution I was provided did not
work and I still need some assistance with this. Any help
would be greatly appreciated.

******** Previous Messages ***********

thanks for the info. I tried this and this doesnt work.
These are unbound listboxes on the form. I tried
referencing the masterfields to the names fo the controls
that store the value on the main form, but this too did
not work.

Any other ideas?

-----Original Message-----
you can set multiple field pairs in the child / master link field
definition. Then when you change the values in the main forms controls, the
subform data will change to reflect those changes.
open the form in design view and select the subform control, then open it's
properties box
now use the link child field and link master field to create the pairs with
the ... build button or select the pairs yourself. the syntax is
link child field
fieldone;fieldtwo;fieldthree;fieldfour (field names in
subform)
link master field fieldone;fieldtwo;fieldthree;fieldfour (field names in
main form)




.
..
 
A

Albert D. Kallal

Assuming that your sql is correct, then I would simply stuff the sql into
the listbox.

It is not clear if you want the results of the sql to show the resulting
list in a listbox, or you want the resulting sql to show in the sub-form?

Further, it is not 100% clear, but are we to assume that this code is run
from the main form, and not the sub-form?

You can easily set the record source of the sub-form from the main form as
follows:

me.MySubForm.Form.RecordSource = "your sql goes here"

Perhaps you are trying to reference text boxes in the main form, but run the
code in the sub-form? (not 100% clear).

Anyway, the above will work (just remove all that child/parent setup that
someone mentioned to you...you don't need, nor want that).

If you are trying to display the results of the sql in a listbox, then
again, you can stuff the sql direct into the listbox control. Again,
assuming the code is in the main form, you would get:

me.MySubForm.Form!myListBox.RowSource = "your sql goes here"

I tend to prefer using a sub-form that starts out un-bound, and stuffing the
sql into that (.RecordSouce). Sub-forms make very nice grids. Here is some
screen shots that does the above idea:

http://www.attcanada.net/~kallal.msn/Articles/Grid.htm
 
M

matt Weyland

Albert,

Thanks for your recommendation. I apologize for the
ambiguity in the question, but you did address the issue.
I am looking to hve the subform reflect the results of the
selected values from the combo boxes on the parent form.

I took your suggestion with dynamically creating the sql
statement and passing that in as the recordsource to the
subform and after the refresh event everything is good to
go.

Thanks once again.
 

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