Solved

requery macro command for a form with 2 subforms

Posted on 2002-05-29
7
524 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

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.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

695 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