Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Those damn calculated controls & bound controls!

Status
Not open for further replies.

Sensibilium

Programmer
Apr 6, 2000
310
GB
I have an order entry form, including a subform, but I am having problems saving the 'OrderValue' field in my 'tblPUOrders' table, please see below my code under the main form (frmNewPurchaseOrder):<br><br>&lt;-----------<br>Private Sub Form_BeforeUpdate(Cancel As Integer)<br>&nbsp;&nbsp;&nbsp;&nbsp;If IsNull(CountryOfOrigin) Then Me!CountryOfOrigin = GetOriginCountry(SupplierID)<br>&nbsp;&nbsp;&nbsp;&nbsp;If Not IsNull(ProductType) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Me!OrderValue &lt;&gt; DollarOrderValue Or IsNull(Me!OrderValue) Then Me!OrderValue = DollarOrderValue<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StdDuty = GetDutyRate(Me!CountryOfOrigin, Me!ProductType)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StdValue = GetStdSterlingValue(DollarOrderValue, StdDuty)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StdExchange = DollarRate<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StdDuty = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StdValue = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StdExchange = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;PUOrderID.SetFocus<br>&nbsp;&nbsp;&nbsp;&nbsp;Me.Refresh<br>End Sub<br><br>Private Sub Form_Current()<br>&nbsp;&nbsp;&nbsp;&nbsp;If Not IsNull(CountryOfOrigin) Or Not IsNull(ProductType) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StdDuty = GetDutyRate(Me!CountryOfOrigin, Me!ProductType)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StdValue = GetStdSterlingValue(DollarOrderValue, StdDuty)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StdExchange = DollarRate<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.Repaint<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>End Sub<br>--------------&gt;<br><br>If I put a break in the code, it works and updates the underlying table! If I remove the break, it doesn't work! The controls that are affected are OrderValue & StdValue. In fact, when the break is removed both these controls reset to 0.00 for each record looked at through this form.<br><br>'CountryOfOrigin', 'ProductType', 'SupplierID', 'OrderValue' are all bound controls (to tblPUOrders)<br>'StdDuty', 'StdValue', 'StdExchange', 'DollarOrderValue' are all unbound controls.<br>'GetOriginCountry', 'GetDutyRate', 'GetStdSterlingValue' are Functions in my global VB Module (all correct).<br><br>'DollarOrderValue' is a calculated control taken from the subform control 'SubformTotal' (Sum(tblPUOrderDetails!LineTotal)), this is always calculated correctly.<br><br>Please help, I've been avoiding this problem for about 3 weeks, but I really need to finish this particular form.<br><br>Thanks in advance.<br>
 
I guess that the problem is the &quot;repaint&quot; in form_current event. The reason is that &quot;me.repaint&quot; is the only code that does not run (for the form) when you set the break but runs when you remove the break.<br><br>Try disabling &quot;me.repaint&quot;<br><br>
 
Thanks for your help, but unfortunately removing 'Me.Repaint' makes no difference I'm afraid...<br><br>That is one of the commands that I regularily swap with Me.Refresh, etc. so that is definitely not the problem here<br><br>:eek:(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top