UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Me.Recalc for continuus form    
 
   
psatkar
post Jun 8 2009, 07:23 AM
Post #1

New Member
Posts: 19



Hi,

I have a continuous form showing 4 different text boxes. Three text boxes are bound to a table. 4th text box is unbound and has datasource as = [txtBox2] - [txtBox3]. I have code Me.Recalc in OnLoad event of the form.

This form has been placed as a subform in main form and height for this subform control is such that it displays 8 records (if there are more records then it provides vertical scroll bar in the subform).

What I have observed is that txtBox4 is calculated only for those records which are currently visible on the subform. For all the other records in subform which needs to be viewed using verticla scroll-bar, this control is not refreshed / calculated and when I click on this contol in Form View, it shows the calculated value

I even tried by using oncode to recalculate the fields by using code Me.Recalc on my main form OnLoad event. But still can not make it work

Do you have any suggestions?
Go to the top of the page
 
+
theDBguy
post Jun 8 2009, 09:58 AM
Post #2

Access Wiki and Forums Moderator
Posts: 48,062
From: SoCal, USA



Hi,

It is odd that the calculated control does not update automatically. I think placing Me.Recalc in the Load event of a form is unnecessary. Try taking it out to see what I mean.

Can you post a small copy of your db with test data?
Go to the top of the page
 
+
psatkar
post Jun 8 2009, 11:08 PM
Post #3

New Member
Posts: 19



Thanks theDBguy....even I was curious as to why is it happening...

After further debugging I noticed that in the control source of the calculated text control had the following formula:

= [txtBox2] - Nz([txtBox3])

If I remove Nz function from this formula and change to just = = [txtBox2] - [txtBox3] then the controls are getting updated properly with Me.Recalc

Not sure why Nz should cause this issue.
Go to the top of the page
 
+
MarkLiquorman
post Jun 9 2009, 06:59 AM
Post #4

UtterAccess Guru
Posts: 578
From: Florida, USA



Rather than referring to the textboxes in the control source, why not directly referenece the fields that are bound to the respective boxes? Example: = [Field1] - [Field2]

Another option is to use a query as the recordsource for the subform, rather than a table. It would be something like this:

SELECT Field1, Field2, Field3, Field2 - Field3 AS Difference FROM myTable

The controlsource for your txtBox4 would be "Difference".
Go to the top of the page
 
+
theDBguy
post Jun 9 2009, 11:32 AM
Post #5

Access Wiki and Forums Moderator
Posts: 48,062
From: SoCal, USA



Hi psatkar,

Glad to hear you got it fixed. You might also try what Mark suggested.

Good luck with your project.
Go to the top of the page
 
+
psatkar
post Jun 9 2009, 11:16 PM
Post #6

New Member
Posts: 19



Thanks Mark,

Infact just to explain the logic which I have adopted, I gave txtBox1 and txtBox2 as examples....In reality I am using the underlying bound fields only for this purpose.

But yes, your suggestion of writing query is more practical. Let me adopt that.

Thanks....

psatkar
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 24th May 2013 - 05:07 AM