opening a form based on a filter

  • Thread starter Thread starter shakeel
  • Start date Start date
S

shakeel

hello sir

thanks in advance for help

i have combo boxes in my form with the name form1
the combo boxes look up values through a query,by
assigning the query to the recordsource property of the
comboboxes.

i now filter the form1, and now i want to open another
form with name form2 with the filter expression that i had
applied to the form1.THE FILTERED EXPRESSION MEANS OR CAN
BE SEEN BY GOING TO THE 'PROPERTIES' OF THE "form1" AND
THEN GOING TO THE 'DATA' PROPERTY AND THE UNDER THE
'DATA' PROPERTY WE HAVE THE 'FILTER'--row THE CONTENTS OF
THIS FILTER--row IS THE FILTERED EXPRESSION THAT I TALK
ABOUT.

i want to use that filter expression and open another form
with that filter expression.

the filter expression changes and will change when i apply
a new filter to the form1 and now i should open the form2
with the new filter expression.

plz help me

thanking you
shakeel
(e-mail address removed)
 
Sure, use the "filter" from from1 as the "where" clause in from2

The only real difference between opening a form with a filter and a "where"
clause is that the "where" clause is NOT saved with the form

So,

behind your button in form1 to open form2, you can use


docmd.OpenForm "form2",,,me.Filter
 
I have a quick question....I had previously posted under
GoToRecord. Will this method work with a subform also?

Thank you.

Ginger
 
The user wants to press a button on a form, and have a new form launched
with the same filter.

You are correct to assume that using the "where" clause on the form will
work just fine with a sub form. So, yes...you can use the same idea with a
sub form.

The real question here is where is the button? Is the button in the sub form
also?

If you look at the following screen shots, you can see a button beside each
record...so, in the following, yes, I do use a sub-form, and the same
code/idea will work.


http://www.attcanada.net/~kallal.msn/Search/index.html

So, you will use whatever field in the sub-form that is the "keyid" of
reocrd that you want to launch to.


docmd.OpenForm "the form",,,"id = " & me.id

The above code is all you need behind the button.

You will of course replace what ever field "id" is with whatever field is
the key id in the main form. If the field is on the main form, then just
replace the above with:

docmd.OpenForm "the form",,,"id = " & me.SubFormContorl.Form.id

It is very likely that you may have not used the field of "id" for your
field name in the sub-form. Use whatever field is used to link to the main
form in that case.
 
Thanks Albert.

Actually I have 2 buttons I have been trying all night to
get working. One is done with a macro and the other is with
the wizard. Neither will recognize the subform name. Could
there be something else causing it not to work?

I had renamed it once to be without spaces, but then went
back to the spaces.

I had worked with other postings under GoToRecord, but
nothing seems to make this work.

Any suggestions are greatly appreciated.

Ginger
 
Back
Top