Update a query embedded in a form

A

Andy Kaye

I have a form which is used to input products that we manufacture. I have
embedded a query in the form which will summarise the total number of each
type of unit on that particular order. Is there a way that the query can be
updated instantly as I input the products. At present the query only updates
once the record (current form) has been closed down and returned to. I would
like to be able to input products and see the quert update instantly.
I'd be grateful for any advice.
Thanks.
 
J

Jeff Boyce

Andy

You & I may have a different meaning for "query". How have you "embedded a
query in the form"?

If you are saying that your form has a way to display a count for each "type
of unit", how are you doing that in your form?

If you are using an Access query to derive the values (?a Totals query,
GroupedBy TypeOfUnit?), are you requerying the control to force Access to
re-run the query after each "input"?

Regards

Jeff Boyce
<Office/Access MVP>
 
A

Andy Kaye

It's added to the form such that it appears as a sub-form on the object menu.
Is this what you meant?
 
L

Lynn Trapp

A

Andy Kaye

Jeff,

Thanks for responding. I'll talk you through the process in basic terms, as
i'm a novice to this and not completely sure how to answer your question.

I've created a query using the wizard and then tailored it in design view to
give me the results i'd expect. I've then opened my form and gone into design
view and used the toolbox to insert a subfrom. Using this method i've
selected the query from the available list and displayed the results in
datasheet view. Currently the query does not update as I input information in
the main part of the form as i would wish. Instead I have to leave the form
and then return to it to view the updated query results. The intention is to
use it as a summary in the finalised form.

I'm beginning to suspect that i'm approaching it from the wrong angle and
may need a different technique. If this is the case I'd be grateful for
pointers on what technique I should be using so that I can read up on it.

Regards,
Andy
 
A

Andy Kaye

Lynn,

Thanks for getting back to me,

That sounds like what i've done. The query was inserted using the toolox in
"form design view" to insert a subform, and as you point out I do have to
re-query it to get it to update.

Perhaps I need a different approach? I'd be grateful for any pointers but
thanks for your help in any case.

Regards,
Andy
 
J

Jeff Boyce

Andy

If you have a main form/subform design, there are properties associated with
the subform control (not inside the subform, but the subform control on the
main form). These properties allow you to set which field(s) in the subform
control are related to a "parent" field in the main form.

You would not need to requery at all if you make that "parent-child"
connection.

On the other hand, if the subform data bears NO relationship to the main
form data, you'd have to add code/procedure to the main form, in one of the
controls' AfterUpdate event to tell Access to requery the subform's source.
You'd do that with something like:
Me!MySubform.Requery
 
Top