Solved

subform / main form not recalculating with SQL Server

Posted on 2014-11-10
4
299 Views
Last Modified: 2014-11-28
I have an access XP app that is being converted to 2013  with SQL Server.    There is a typical subform / main form with a subform with Quantity, Retail, Days and calculated control Amount (controlsource==[Quantity]*[Retail]*[Days] )

On the older version working since 2.0, when Quantity was updated, Amount would update, When that line was updated, the subtotal on the main form would update.  Now Neither update happens.

I have been able to force the Amount control in the line to update with an Me.Amount.Requery in the afterupdate of Quantity, Retail, and Days.  That is nice and clean.

Subform Detail Controls:
  Quantity, Retail, Day, Amount (controlsource = =[Quantity]*[Retail]*[Days])
   
Subform Footer Controls:
   Subtotal (controlsource = =Sum([Quantity]*[Retail]*[Days]) )

Main Form Controls:
   Subtotal =IIf(IsNull(Forms!frmJobs!ctl_subLI.Form!Subtotal),0,Forms!frmJobs!ctl_subLI.Form!Subtotal)

I have tried many variations to get the subtotal to update WITHOUT a requery or recalc.  When i do that it sends the cursor back to top.

I have the subform visible and can see that the subform total does not update when you move off the detail record to and detail record.

Here is the Subform After Update and some of what i have tried.  Non work with a whole refresh or requery.

    Me.Amount.Requery
    Me.Subtotal.Requery
    Me.Refresh
   
    Me.Parent.Subtotal.Requery
    Me.Parent.Refresh  ' This will make it update, but moves cursor to top
   
    'Me.Recalc ' this will work but moves cursor to top

Is there a way to resolve this behavior?  I would rather not have to whole form refresh since the way it repaints is not that nice, and the cursor goes to top.
0
Comment
Question by:pressMac
  • 3
4 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40434689
Have a look at the solution regarding a similar question on this page: http://www.experts-exchange.com/Database/MS_Access/Q_28551520.html

Basically, I would refresh the data, and then use DoCmd.GoToRecord to go back to the record where you were.

Regarding the refresh not looking nice, I would suggest using

me.painting = false
(Do the refresh, then the DoCmd.GoToRecord)
me.painting = true

Open in new window


or

Application.Screenupdating = False
(Do the refresh, then the DoCmd.GoToRecord)
Application.Screenupdating = True

Open in new window

0
 

Author Comment

by:pressMac
ID: 40439669
I will try this, but interested to know why the behavior is different than before.
0
 

Accepted Solution

by:
pressMac earned 0 total points
ID: 40460617
I ended up using the following in the subform afterupdate.   So, i did not have to do a form requery.    

    Me.Amount.Requery
    Me.Subtotal.Requery
    Me.Refresh

and the following in the mainform afterupdate:

    Me.Subtotal.Requery
    Forms!frmjobs!Subtotal.Requery
0
 

Author Closing Comment

by:pressMac
ID: 40470194
I did not really use the solution, but it helped me find the solution.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access Schema 6 24
SQL 2012 clustering 9 11
SQL Recursion schedule 13 14
2 subforms 1 main form 1 12
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

839 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