Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query constantly displayed in a form 2

Status
Not open for further replies.
Sep 10, 2002
150
US
I have a query that displays the sum of 7 fields. I want the result of that query to be constantly displayed in a box on my form, and every time I change one of the values in the field, I want the sum to automatically update as well. Is a query the best way to do this? If so, how? If not, is there a form related function I can do instead? Thanx!!!!!
 
this is the way i did it:

you make another form that shows a single field "sum" (that shows the calculated sum from the query you have made previousely). Make this form small and make sure there are no dividing lines, record selectors, navigation buttons, scroll bars, and borders. Then put this as a subform on the form that displays the records that make up the sum and do not link it to the parent form. just let it be there.

If the sum needs to be linked to a specific ID number, or record number - put in the small form another control , ID or record number control, make it invisible. and then when you put the subform on the main form, link the id, of record number controls.

This should work.

please post your feedback
REGARDS, KUZZ

LIFE IS GREAT WHEN THERE IS SOMEONE TO HELP YOU.
DESIGNING DATABASES SINCE 2002
 
Great, that's a majority of the battle. The only other realy issue I have is a nitpick, can I make it instanly update the total? As is, I can only make the total update is if I close the record and reopen it. Can this be done either automatically or through a button? Also, is this type of relationship easy displayable on a report? Thanx!
 
you can, follow the code by the next two lines

DoCmd.DoMenuItem acFormBar, 1, 12, 3, 70
DoCmd.DoMenuItem acFormBar, 1, 12, 2, 70

hope that works REGARDS, KUZZ

LIFE IS GREAT WHEN THERE IS SOMEONE TO HELP YOU.
DESIGNING DATABASES SINCE 2002
 
Where exactly do I put this in the code and on which form, the main form or the subform? I've tried both and I can't seem to get it to work.
 
this put in for code on the form, say forAFTER_UPDATE

for the subform, try to use REQUERY for ONCLICK may be, you have to experiment.

For report, that will work, only you will have to make an identically structured subreport, as the subform, and put it in the main report REGARDS, KUZZ

LIFE IS GREAT WHEN THERE IS SOMEONE TO HELP YOU.
DESIGNING DATABASES SINCE 2002
 
On each of the 7 fields you enter into, put an after update event that requeries the subform that has the total.

subformcontrolname.requery
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top