Hi John,
To accomplish this, you need some code in the form which is opening,
to (1) get the value from the calling form's combobox, then (2) use
that value to filter the form which is opened.
In the Open event of the form which is being opened (frmPackaging),
set the value of cbMainSelect as the value of the combobox:
Me.cbqrytypes =
Forms("KEYSTONEeditids").Controls("cbMainSelect").Column(2)
then apply that via the existing code for the combobox's AfterUpdate
event (I'm assuming that you have code there to filter the form's
records in some fashion):
Me.cbqrytypes_AfterUpdate
Depending on exactly what your code in cbqrytypes does, you may find
that this won't work in the form's Open event, because at that time
there are no records loaded. If it doesn't work there, put it in the
form's Load event and it should be OK.
Note that this requires that the calling form ("KEYSTONEeditids") is
still open (it may be hidden) when frmPackaging opens. From the code
you posted earlier, that seems to be the case. If it's not, then put
the value from cbMainSelect.Column(2) into the OpenArgs parameter
when you open frmPackaging and retrieve it from there when
frmPackaging opens.
HTH,
Rob
johnlute wrote:
I'm afraid I don't really understand exactly what you're trying to
do. Or perhaps, you're not understanding Access well enough to
describe your problem.
It's both. And your not understanding is due to my ignorance
You say "I'm trying to open a form with its control [cbqrytypes]
filtered ..." which rather confuses me. The DoCmd.OpenForm
statement, when supplied with a Where parameter (in this case, your
strCriteria), will open the specified form (in this case, the form
given by strFormToOpen) with its RecordSource filtered by
strCriteria.
This is something I've obviously never wrapped my brain around. Yes,
in this case the form given by strFormToOpen is what I'm trying to
open WITH its control [cbqrytypes] filtered to the value in [Forms!
[KEYSTONEeditids].Form![cbMainSelect].Column(2)
I don't understand what you mean by "... its control [cbqrytypes]
...". Are you meaning that the value of [cbqrytypes] (whatever
[cbqrytypes] is - this syntax generally refers to a field name) is
the RecordSource for your form which is opening?
No.
Or does [cbqrytypes] contain the name of a control on the
form you are opening - a combobox, perhaps - and are you trying to
set its RecordSource to something filtered by the selection in the
unbound cbMainSelect control on your current form when you open the
form?
We're getting closer! [cbqrytypes] IS the control (a combobox) on
the form that I'm opening. It also serves as a filter for the form.
Here's the form's record source:
SELECT tblProfiles.*, tblProfiles.Type AS PKType
FROM tblProfiles
WHERE (((tblProfiles.Type)=[Forms]![frmPackaging].[Form]!
[cbqryTypes])) OR ((([Forms]![frmPackaging].[Form]![cbqryTypes]) Is
Null));
So...[frmPackaging]is opened from the "Main Menu" [KEYSTONEeditids]
via its control [cbMainSelect]. With the [frmPackaging] opened to
the filtered value AND upon editing the desired record - a user
will want to clear [cbqrytypes] OR make another selection to filter
for another group of entities.
Scenario: from the Main Menu a user selects "Cups" from
[cbMainSelect]. The "Cups" record has a "CP" value in the 2nd column
of [cbMainSelect] and a "PK" value in the 1st column of
[cbMainSelect]. So I'm trying to get [frmPackaging] to open and
filter to the "CP" value. After editing the desired Cup record(s)
the user wants to navigate to the "Glass Bottles" group so rather
than closing the form and going back to the Main Menu they simply
select "BTGL" from [cbqryTypes].
This may seem a bit nuts. I suppose the question would be: Why not
just have [cbMainSelect] list "Packaging" as a value to open
[frmPackaging] and then filter to whatever group a user wants? That
crossed my mind however, it's so much more user-friendly to list all
of the groups in [cbMainSelect] so that a user can open
[frmPackaging] to their desired group without having to think or
remember to filter it once they've opened it.
This is all on the heels of a major re-design. I'm now using a
single form for ALL packaging types. Previously I used ONE form for
EACH type. Whittling things down to one form is an enormous
improvement however it's created this challenge here. Here's more
info on the re- design:
http://groups.google.com/group/microsoft.public.access.formscoding/br....
Clarification needed before I can assist further,
I hope that helps! Sorry for the length. I couldn't find an easier
way to describe. As I've spelled it out it's become somewhat
apparent that I've got the wrong approach. I'm not sure however
because I;m not real clear on the trick of opening forms per a
criteria.
Thanks for your help!- Hide quoted text -
- Show quoted text -- Hide quoted text -