Solved

Form/Subform Running Total not Updating

Posted on 2011-02-22
7
405 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
Comment Utility
Hi,

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

Best regards,

Bill
0
 
LVL 1

Author Comment

by:atreidies
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 14

Accepted Solution

by:
Bill Ross earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Please post the SQL for qryRunTotal
0
 
LVL 1

Author Comment

by:atreidies
Comment Utility
Perfect once I changed Recerd to Record...thanks!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
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.

772 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

10 Experts available now in Live!

Get 1:1 Help Now