Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Form/Subform Running Total not Updating

Posted on 2011-02-22
7
Medium Priority
?
461 Views
Last Modified: 2012-05-11
In my Form/Subform relationship the subform contains a checkbox I would like that each time the checkbox is either set to true or false the running total on the the main form would requery.  It seems to only update after a second action has been performed.  When I check one box my total says $0.00 after I make a second it reflects the total amount from the first selection.

Here is what Im using:


Dim RunningTotal As String
If DCount("*", "[qryRunTotal]") > 0 Then
    RunningTotal = DLookup("[RunTotal]", "[qryRunTotal]")
    Forms!frmToBeAdjusted!Text57 = RunningTotal
Else
    RunningTotal = "$0.00"
    Forms!frmToBeAdjusted!Text57 = RunningTotal
End If

Open in new window

0
Comment
Question by:atreidies
  • 5
  • 2
7 Comments
 
LVL 14

Expert Comment

by:Bill Ross
ID: 34952359
Hi,

You need to place the calculations in the AfterUpdate event of the checkbox.

Best regards,

Bill
0
 
LVL 1

Author Comment

by:atreidies
ID: 34952391
Ive tried the After/Before events of the subform, form and even the check box they all seem to be one total behind.
0
 
LVL 14

Expert Comment

by:Bill Ross
ID: 34952418
Hi again,

In looking at your code if the query relies on data that may nave been updated then you need to save the record.  This is in addition to putting the code in the AfterUpdate event of the checkbox.

Add:

DoCmd.RunCommand accmdSaveRecerd

as the first line in the AfterUpdate event then run your process to get the subtotal.

Regards,

Bill
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 14

Accepted Solution

by:
Bill Ross earned 2000 total points
ID: 34952444
Sample...

Pricvate sub_MyCheckBox_AfterUpdate()
  Dim RunningTotal As String
  DoCmd.RunCommand accmdSaveRecord
  If DCount("*", "[qryRunTotal]") > 0 Then
     RunningTotal = DLookup("[RunTotal]", "[qryRunTotal]")
     Forms!frmToBeAdjusted!Text57 = RunningTotal
  Else
     RunningTotal = "$0.00"
     Forms!frmToBeAdjusted!Text57 = RunningTotal
  End If

End sub
0
 
LVL 14

Expert Comment

by:Bill Ross
ID: 34952498
Hi,

In general if you are running a query that is using data on the form you need to push that data bak to the db so the query can find the current values.  You can put a running total on the form footer and get the result you are seeking without code if trhe values to be summed up are on the form.

Set the recordsource for Forms!frmToBeAdjusted!Text57

=Sum([FieldName])

That will always display the total.

Bill
0
 
LVL 14

Expert Comment

by:Bill Ross
ID: 34952506
Please post the SQL for qryRunTotal
0
 
LVL 1

Author Comment

by:atreidies
ID: 34952524
Perfect once I changed Recerd to Record...thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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.
Suggested Courses

824 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