Solved

subform / main form not recalculating with SQL Server

Posted on 2014-11-10
4
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

729 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