Solved

Recalculate fields after requery.

Posted on 2010-08-27
6
626 Views
Last Modified: 2012-05-10
I have a form with a subform and calculated field.  When the form opens the subform has no control source.  There is a field on the main form where the user enters a date and clicks "Submit".
The following events then take place:
Subform control source is set to a query.
Main form date is passed to subform/query and records are returned.
One subform field sums up a field from all records (this was in the footer of subform, now in main section of subform).
Control Source gets set for calculated field on main form (see below).

The calculated field on the main form is linked to the subform field that totals up all records.  I just want to show the total on the main form.  I should note that the calculated field on the main form is unbound upon opening the form, but the control source gets set after the control source is set for the subform.

Issue:  The calculated field on the main form is blank after clicking "Submit" and after records are returned.  I'm pretty sure this is a timing issue because I have a button that just calculates the total on the main form (when there are subform records present) and it pops up with no problems.

How do I get this field to be calculated after the subform returns all records?

Thanks in advance!
Kelly
0
Comment
Question by:kellysteevens
6 Comments
 
LVL 11

Expert Comment

by:LambertHeenan
ID: 33545726
Try Me.Refresh

That's supposed to force recalculation.
0
 
LVL 75
ID: 33545755
Are you sure you don't mean

Me.ReCalc ....?

mx
0
 
LVL 10

Accepted Solution

by:
t_hungate earned 500 total points
ID: 33545767
I think tht you called it on this one.  I would set an on timer event, 3-5 sec should work from after the time you click on the submit button.  Also, if you are not storing the calculated filed from the main form, you can always set them to mirror. i.e.  

Me.txtMyCalcVal = [Forms]![frmYourSubFrm].[txtSubCalcVal]

TLH
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 11

Expert Comment

by:LambertHeenan
ID: 33545814
Yes indeed. I meant to say Me.ReCalc (stupidly relied on mere human memory)
0
 
LVL 75
ID: 33545908
Can you:

1) Compact & Repair (*** to shrink the size),

2) Zip up the MDB (*** to further shrink the size)

3) Attach the file for upload here (using the 'Attach File function below) ... removing any sensitive data of course.

4**** And please give a clear explanation of exactly how to reproduce the problem or what you are trying to do.

NOTE:  If you have an A2007 ACCDB, please convert to A2003 MDB.
mx
0
 

Author Closing Comment

by:kellysteevens
ID: 33546499
I am not too bright today.  I had originally set the source of the fields in the control source properties (the easy way), but when the form loaded with no submit date, the fields *I thought* said "Name?" which I thought was confusing to the user.  So then I spent hours over-thinking things and was trying to problematically get the value.

I went back and did it the easy way as suggested and it worked fine and now calculates correctly.  Thanks for all the help!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dsum Function for List Box Data 7 45
ms access 2010 vba, copy table from db1 to db2 from db3 27 46
Access 2016 7 33
Create macro from runcode 30 24
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…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

776 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