Solved

requery macro command for a form with 2 subforms

Posted on 2002-05-29
7
518 Views
Last Modified: 2012-06-27
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
Comment
Question by:lennygw
7 Comments
 
LVL 12

Expert Comment

by:James Elliott
ID: 7042965
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
 

Author Comment

by:lennygw
ID: 7043072
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
 
LVL 1

Expert Comment

by:dynamictiger
ID: 7043117
I think you need to set the focus into the main form first, then requery the subform, using Me.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 3

Accepted Solution

by:
MCummings111400 earned 100 total points
ID: 7043515
Try this

Me.Parent.sfrmUsage.Form.DaysUsed.Requery
0
 

Expert Comment

by:Oxman39
ID: 7043569
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
 

Author Comment

by:lennygw
ID: 7044318
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
 

Author Comment

by:lennygw
ID: 7044329
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now