Link to home
Start Free TrialLog in
Avatar of pressMac
pressMacFlag for United States of America

asked on

subform / main form not recalculating with SQL Server

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.
Avatar of Phillip Burton
Phillip Burton

Have a look at the solution regarding a similar question on this page: https://www.experts-exchange.com/questions/28551520/Refreshing-Data-On-A-continuous-Screen-without-using-Requery.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

Avatar of pressMac

ASKER

I will try this, but interested to know why the behavior is different than before.
ASKER CERTIFIED SOLUTION
Avatar of pressMac
pressMac
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I did not really use the solution, but it helped me find the solution.