form - subform

  • Thread starter Thread starter Jean-Paul De Winter
  • Start date Start date
J

Jean-Paul De Winter

Hi,
Hope I can explain this in a clear way...
I have a form with some listboes and a subform.
Th subform is based upon a query
the SQL from the query is:
Select patienten.naam, patienten.afdeling from patienten where
(((patienten.afdeling)=forms!rapporten!afdeling));
afdeling is the name of a listbox on the form.
When opening the form, nothing is displayed in the subform
When I open the subform I am asked to enter what should be found in the
listbox, I get what I
want.
It looks like the query is run before the form is actually opened so nothing
is found in the
listbox.
How should I solve this problem??
Thanks
 
Jean-Paul,
When you open the main form, I presume that you have not
selected any item from the listbox yet. So, the subform is
empty.
You might want to first base the record source of the
subform on the query without a where clause so you can see
all records. Then when you select an item from the list,
dynamically change the record source of your subform, or
filter the subform based on the selection.
Geof.
 
What is the best way... to create a filter or to change the record source?
What's the difference?
Thanks

Op Fri, 8 Oct 2004 13:38:56 -0700 schreef Geof Wyght
 
Jean-Paul,
Filter. That way you don't have to change the query. You
need 2 lines:
for the listABC after update event on the main form:
Me.Controls("subformname").Forms.Filter = "field1 = " &
Me.listABC.Column(0)
Me.Controls("subformname").Forms.FilterOn=True

If you have a Clear button for your list:
Me.Controls("subformname").Forms.Filter= ""
Me.Controls("subformname").Forms.FilterOn=False

I think I got that right.
Bonne chance.
Geof.
 
Forgot to explain the difference. If you change the record
source, you are being more restrictive. Filtering is more
flexible and slightly faster. No need to requery or
refresh the subform.
 
This confuses me a bit

Me.Controls("subformname").Forms.Filter = "field1 = " &
Me.listABC.Column(0)
Me.Controls("subformname").Forms.FilterOn=True

you set the filterOn=true after you have set a filtering... why not first
set it to true?
What is that column(0) needed for?

Thanks for your kind help...
(BTW... you are French?)
JP

Op Fri, 8 Oct 2004 13:52:16 -0700 schreef Geof Wyght
 
Jean-Paul,
I believe that you first set the filter string then turn
it on. I recall that's the order in the text books. I
don't think it'll break the other way around.

I'm from Ottawa, Ontario, Canada. 25% francophone.
Geof.
 
Back
Top