Beth said:
I have created a form with a subform based off the same
query. The query askes for a parameter value to select a
single account number.
My problem lies in that when I bring up the form it asks
me to enter the parameter value 3 times.
Is there a way to link this information so it only has to
be entered once? It is the exact same data.
Thanks!!!
Hi Beth,
Using the same parameterized query for two forms you open simultaneously
(basically what you're doing) means that the query will of course run at
least twice, and you will be prompted for a value at least twice. In
fact it isn't asking you for the same parameter value, because as the
program sees it, you've asked it to execute the same query more than
once, and for each execution, it requires input; so all the prompts are
for separate values.
(I'm guessing that the reason you're prompted three times is because
that Access queries the subform, then the main form, then the subform
again, but I don't know why it would do that. I do know it opens
subforms before main forms.)
How to link? First off, I must question your design. If these two
forms are using the same query, and you want to link them so that they
run with the same parameter data, why do you need a subform? Why not
just build the subform controls into the main form? Do you use
alternate subforms in the main form, or do you use the subform
separately from the main form? If the answer to these questions is No,
and will remain No, I suggest you not use a subform, but add your
subform controls to the main form.
If for some reason this isn't an option, then try the following:
-) Add a control to the main form. This will be where the user enters
the parameter.
-) Change the main form's record source so that where you have an input
prompt, there is now a reference to this control, a la Form![Form_name]!
[Control_name]. (Someone correct me if this is wrong, I'm going by
memory on a practice which I never liked.)
-) Remove the input prompt from the record source for the subform.
-) Set the main form's subform control to link on the field that you
originally had recieving the user input.
Now when a user enters an account ID into the new control on the main
form, the forms should requery to show the proper record. (Again,
someone correct me if my memory is faulty.)
There are other ways to do this but it would involve code.
hope this helps
spark