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

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Values in textbox not reflecting change after update and requery    
 
   
dawatson
post Oct 9 2009, 08:15 AM
Post #1

UtterAccess Addict
Posts: 108



I have a textbox control on a main form (txtInstallation) with the control source set to
=IIf([Form].[NewRecord],Null,nz([fsubConfigDeliveryOptions].[Form]![txtDeliveryT
otal]))

The control source references a textbox (txtDeliveryTotal) on the subform that has a control source of
=IIf([Form].[NewRecord],Null,Sum(nz([DeliveryCost],0)*nz([Qty],0))).
The deliverycost and qty is a field in the subform.
The textbox is hidden in the datasheet.

The control does contain the correct value for the sum when the form is
first displayed / records in the main form are access by pressing the navigation controls

When I navigate through the records in the main form, the value displayed in the controls on the main form
and the subform is correct.

My problem occurs after I update the control (txtQty) on the subform that has control source of [Qty].
In the afterupdate event of that control I have the code:

txtDeliveryTotal.Requery
Me.Parent.txtInstallation.Requery

I need to accomplish a simple task. After the qty value in the subform is updated, I want the new sum value stored in the textbox txtDeliveryTotal to be displayed in the textbox on the main form. I thought after requerying the textbox on the subform that stores the sum and then requerying the textbox on the main form the correct value would be displayed.

Instead the textbox is empty. If I debug.print the textbox.value of either control after the requery both of them contain the value they were before the qty field was updated. If I navigate from the current record on the main form and then return to the edited record, then the values are correct.

How do I reflect the correct the values in the text main form after the subform is udpated.
Go to the top of the page
 
+
GroverParkGeorge
post Oct 9 2009, 09:43 AM
Post #2

UA Admin
Posts: 21,407
From: Newcastle, WA



This might reflect the fact that the record in the subform has been edited, but not yet saved. Moving focus to another record and back is forcing the save. Try this: add a line to the code to force the save in the subform :

If Me.Dirty Then Me.Dirty = False
txtDeliveryTotal.Requery
Me.Parent.txtInstallation.Requery
Go to the top of the page
 
+
dawatson
post Oct 9 2009, 12:04 PM
Post #3

UtterAccess Addict
Posts: 108



GPG
I had already thought of that. The values still don't change.

Congrats on 10K. Sadly for me I do no posting for others. All my post are for help.
Go to the top of the page
 
+
GroverParkGeorge
post Oct 9 2009, 07:40 PM
Post #4

UA Admin
Posts: 21,407
From: Newcastle, WA



Thanks.

It surely should work that way and it did in my quick test.

I may have missed a step, but I think not. Anyway, try this. Before requirying the control on the main form, use the SetFocus method to move focus to it.

Perhaps, you can upload some sample data to look at. It must be compressed with a tool like WinZip and under 500KB in size.

Edited by: GroverParkGeorge on Fri Oct 9 21:06:04 EDT 2009.
Go to the top of the page
 
+
dawatson
post Oct 10 2009, 12:14 PM
Post #5

UtterAccess Addict
Posts: 108



I setfocus to the control on the main before the requery and that corrected the problem.
Why would the setfocus have this affect on the requery?
Go to the top of the page
 
+
GroverParkGeorge
post Oct 10 2009, 12:32 PM
Post #6

UA Admin
Posts: 21,407
From: Newcastle, WA



Ah, well. It occurred to me, somewhat belatedly I'm afraid, that you are working with a form/subform, and focus between them is a factor. VERY recent discussion (IMG:http://www.utteraccess.com/forum/style_emoticons/default/blush.gif)
Go to the top of the page
 
+
dawatson
post Oct 10 2009, 12:43 PM
Post #7

UtterAccess Addict
Posts: 108



I spoke to soon.

There's still several problems. After I press enter on the txtqty field on the subform, the main form displays the correct value only if I click on a column in the same row. If I click on a different row, then the main form control display is blank.


I place the same code in afterdelconfirm and afterinsert event.

If I delete a row in the subform, the main control is empty.
If I insert a row in the subform, I have to click on a different column in the same row for the main form to display the correct data. Once I click on a different column is the same row the main always displays the correct amount.
If I click on a different row, the main form is blank
Go to the top of the page
 
+
GroverParkGeorge
post Oct 11 2009, 08:45 PM
Post #8

UA Admin
Posts: 21,407
From: Newcastle, WA



These all sound like they are related to the firing of events that update the controls and the state of the recordsets in the subform and main form and to the record with focus in the subform.

If you don't mind, it might be easier if you upload a copy of the database, with sensitive data removed, so we can look at all of the events. It needs to be compressed with WinZip or a similar program and less than 500KB in size.
Go to the top of the page
 
+
dawatson
post Oct 12 2009, 01:13 PM
Post #9

UtterAccess Addict
Posts: 108



I can't upload any part of the db because of company constraints. I'll have to work on it and if I can't find
a solution force the user to click on other columns after modifying the field.

Thanks,
Go to the top of the page
 
+

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

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 24th April 2014 - 10:18 AM