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!

Newbee: Query in subform not automatically updating

Status
Not open for further replies.

rcoutts

Technical User
Sep 5, 2001
60
US
I have a Query that totals up the columns in my Time Card Table. My TimeCard Form looks something like this:
Code:
   Job   Mon Tue Wed Thu Fri Sat Sun Total
   ----- --- --- --- --- --- --- --- -----
   Smith 8.0     8.0     8.0          24.0
   Jones     8.0     8.0              16.0
         8.0 8.0 8.0 8.0 8.0          40.0
Where the last row is a SubForm that has my Query as a source. Every time the the user changes a day/job field, the corresponding table gets updated (I'm bring up the able to verify this.)

The problem is that my Query only updates when the form is opened (not when the field's of the tables it reference change, which is what I want). So, if I close my Time Card and open it again, it gets updated. But, I obviously want to update it everytime the user changes a day/job field.

Can someone clue me in?
Thanks!
Rich
 
If I got your question right, you can use Me.Requery or Me.Refresh after the SQL statement. It will recalculate the values on the form.
 
You should be able run
Code:
SubformName.Requery
on the change, before or afterupdate of the time fields.

 
Thanks for the posts. I got Requery working for me, sort of. I added a button that runs SubformName.Requery when the OnClick Event is triggered. It works great. The problem I'm having now is that I really don't want the user to have to click a button, but rather the values update automatically. I'm running into trouble now because my JobHours table is also in a subform. So, when I try to run SubfromName.Requery on an OnChange event, I get the error "Object Required." It appears that because both my Query Subform and my Table Subform are, well, subforms, there's no Parent-Child relationship, so they can't 'see' each other. Does that make any sense? Its the only thing I can think of since it works fine when I added the button to the Main Form, which has the Query Subform as a child.

So, I guess my question now is how can I make a subform run Requery on another subform? At least I think that's my question. I may be getting ahead of myself here.

Thanks,
Rich
 
Check out the change event which opperates everytime a field is changed. add the requery code in there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top