Solved

requery macro command for a form with 2 subforms

Posted on 2002-05-29
7
520 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
type of query 11 42
Access 2016 - Blank, Null, or empty string? 9 31
Auto Center Controls on a Form Based on Screen Size/Resolution in MS Access 10 38
Top 1 of each supplier 55 56
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

770 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