Solved

subform / main form not recalculating with SQL Server

Posted on 2014-11-10
4
295 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

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…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
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.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

758 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

22 Experts available now in Live!

Get 1:1 Help Now