• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

requery macro command for a form with 2 subforms

Question relates to a database for tracking the "time used" for gages in a factory. I have a main form called "Gage" with a subform "Issues" and a second subform "Usage". Issues' data source is a table that tracks when a gage is issued out for use, and when it returns (field names are DateOut and DateReturned). The Usage subform's data source is a query that calculates the total elapsed time that the gage has been issued. When the DateReturned field (on Issues subform)is modified, I want it to trigger a recalculation of the fields on the Usage subform. I have been trying to use the requery macro without success - the error message is something to the effect... "You can't use the ApplyFilter action on this window...". I have tried a variety of object names for the requery, but none have worked. I am using Access 2000. Thanks for any suggestions.

- Lennygw
0
lennygw
Asked:
lennygw
1 Solution
 
James ElliottCommented:
Put this on the after update event on your DateReturned Field.

docmd.requery([Control Name])

where control name is the reference to the control on your usage form.

Is that what you are looking for?

Thanks

Jell
0
 
lennygwAuthor Commented:
Jell -
Thanks for your response and to answer your question, well yes and no - yes this is the idea, but I can't get it to work. I think the key may lie in the syntax of the control that I'm trying to requery. Remember, when entering the "DateReturned", the focus is in the Issues subform, and I'm trying to get it to trigger a requery of the other subform (sfrmUsage). The syntax: 'forms!gages!sfrmUsage.form!DaysUsed' doesn't work and neither does any other that I've tried. I either get an error that it can't find the field or "You can't use the ApplyFilter action on this window". I think I need the proper syntax to refer to the other subform or perhaps an altogether different solution to update the "usage". Again, any suggestions are appreciated.

- Lennygw
0
 
dynamictigerCommented:
I think you need to set the focus into the main form first, then requery the subform, using Me.
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
MCummings111400Commented:
Try this

Me.Parent.sfrmUsage.Form.DaysUsed.Requery
0
 
Oxman39Commented:
Lennygw,
You shouldn't have to set the focus to the main form to requery a sub form from another event on a separate subform.  If you right click in your code module, select the "List Properties/Methods" option.  Now just scroll down until you see the name of your main form.  Hit the period button and select the subform name.  HIt the period and scroll to Requery.  That should do it.
0
 
lennygwAuthor Commented:
Oxman39,
Thanks for the suggestion. I like the propect of not having to change focus to the main form and I gave it a try - unfortunately, the "List Properties/Methods" did not include the parent form. In fact it only listed 4 of the 12 forms currently in the database.
0
 
lennygwAuthor Commented:
Yes - it worked great. Actually, I shortened it up to requery the whole parent form which recalcs the usage subform - me.parent.requery - Thanks!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now