If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Calculated fields
Hi All
I have a puzzling problem and I cannot figure out where I am going wrong perhaps the experts can help me out here! I have created a form in my database that calculates payment based on the value in one field. I have a field called Question1A and a Text field called Text1A I enter a value in Question1A and the calcualtions are displayed in Text1A and the I have 2 ore fields Question2B and Text2B the combined values in Question1A and Question1B calculate This works ok except when I enter a new record the values from the previous record are displayed and I have to refresh the screen for the default values to be displayed. I have tried enterring the calculations in the before and after update and on form load Question1A and Question1B are both manual entries by user here is a sample of the code The first function calculates what goes into Text1A Private Sub Question1A_BeforeUpdate(Cancel As Integer) If Me.Question1A = "A" Then Me.Text1A = 12* 0 Else If Me.Question1A = "B" Then Me.Text1A = 12* 0.5 * 3 Else If Me.Question1A = "C" Then Me.Text1A = CalculatorField * 4 * 0.5 Else End If End If End If what goes into Text1B Private Sub Question1B_BeforeUpdate(Cancel As Integer) If Me.Question1A = "A" And Me.Question1B = "1" Then Me.Text1B = Me.Text1A * 2 Else If Me.Question1A = "A" And Me.Question1B = "2" Then Me.Text1B = Me.Text1A * 4 ElseIf Me.Question1A = "B" And Me.Question1B = "1" Then Me.Text1B = Me.Text1A * 6 Else If Me.Question1A = "B" And Me.Question1B = "2" Then Me.Text1B = Me.Text1A * 8 Else End If End If End If Please please HELP!!! |
#2
|
|||
|
|||
Calculated fields
LindaBee, I'm having a hard time following this but if your issue is one of
refreshing, then try this. Duplicate the calculation code in the OnCurrent event. That will refresh the calculated fields when you navigate to a new record. -- Danny J Lesandrini www.amazecreations.com "LindaBee" wrote ... Hi All I have a puzzling problem and I cannot figure out where I am going wrong perhaps the experts can help me out here! I have created a form in my database that calculates payment based on the value in one field. I have a field called Question1A and a Text field called Text1A I enter a value in Question1A and the calcualtions are displayed in Text1A and the I have 2 ore fields Question2B and Text2B the combined values in Question1A and Question1B calculate This works ok except when I enter a new record the values from the previous record are displayed and I have to refresh the screen for the default values to be displayed. I have tried enterring the calculations in the before and after update and on form load Question1A and Question1B are both manual entries by user here is a sample of the code The first function calculates what goes into Text1A Private Sub Question1A_BeforeUpdate(Cancel As Integer) If Me.Question1A = "A" Then Me.Text1A = 12* 0 Else If Me.Question1A = "B" Then Me.Text1A = 12* 0.5 * 3 Else If Me.Question1A = "C" Then Me.Text1A = CalculatorField * 4 * 0.5 Else End If End If End If what goes into Text1B Private Sub Question1B_BeforeUpdate(Cancel As Integer) If Me.Question1A = "A" And Me.Question1B = "1" Then Me.Text1B = Me.Text1A * 2 Else If Me.Question1A = "A" And Me.Question1B = "2" Then Me.Text1B = Me.Text1A * 4 ElseIf Me.Question1A = "B" And Me.Question1B = "1" Then Me.Text1B = Me.Text1A * 6 Else If Me.Question1A = "B" And Me.Question1B = "2" Then Me.Text1B = Me.Text1A * 8 Else End If End If End If Please please HELP!!! |
#3
|
|||
|
|||
Calculated fields
Hi Danny
Thanks for the response but I tried this and am still getting values in some fields. I have clculated fields which are updated depending on avlues entered in boud fields. What is hapenning is that when I try to create a new record the calculated values in teh previous record are being carried into the new record, in other words instead of displaying the default value 0 I am getting whatever figure was in the previous record. Does this make sense? "Danny Lesandrini" wrote: LindaBee, I'm having a hard time following this but if your issue is one of refreshing, then try this. Duplicate the calculation code in the OnCurrent event. That will refresh the calculated fields when you navigate to a new record. -- Danny J Lesandrini www.amazecreations.com "LindaBee" wrote ... Hi All I have a puzzling problem and I cannot figure out where I am going wrong perhaps the experts can help me out here! I have created a form in my database that calculates payment based on the value in one field. I have a field called Question1A and a Text field called Text1A I enter a value in Question1A and the calcualtions are displayed in Text1A and the I have 2 ore fields Question2B and Text2B the combined values in Question1A and Question1B calculate This works ok except when I enter a new record the values from the previous record are displayed and I have to refresh the screen for the default values to be displayed. I have tried enterring the calculations in the before and after update and on form load Question1A and Question1B are both manual entries by user here is a sample of the code The first function calculates what goes into Text1A Private Sub Question1A_BeforeUpdate(Cancel As Integer) If Me.Question1A = "A" Then Me.Text1A = 12* 0 Else If Me.Question1A = "B" Then Me.Text1A = 12* 0.5 * 3 Else If Me.Question1A = "C" Then Me.Text1A = CalculatorField * 4 * 0.5 Else End If End If End If what goes into Text1B Private Sub Question1B_BeforeUpdate(Cancel As Integer) If Me.Question1A = "A" And Me.Question1B = "1" Then Me.Text1B = Me.Text1A * 2 Else If Me.Question1A = "A" And Me.Question1B = "2" Then Me.Text1B = Me.Text1A * 4 ElseIf Me.Question1A = "B" And Me.Question1B = "1" Then Me.Text1B = Me.Text1A * 6 Else If Me.Question1A = "B" And Me.Question1B = "2" Then Me.Text1B = Me.Text1A * 8 Else End If End If End If Please please HELP!!! |
#4
|
|||
|
|||
Calculated fields
"LindaBee" wrote in message
... Hi Danny Thanks for the response but I tried this and am still getting values in some fields. I have clculated fields which are updated depending on avlues entered in boud fields. What is hapenning is that when I try to create a new record the calculated values in teh previous record are being carried into the new record, in other words instead of displaying the default value 0 I am getting whatever figure was in the previous record. You could always do the calculations in the form's query. You could use either the "Iif" function or write your own (similar to the code you already have) and pass the fields from the query to it as arguments. Keith. www.keithwilby.co.uk |
#5
|
|||
|
|||
Calculated fields
Its sorted now thanks for all responses
"Keith Wilby" wrote: "LindaBee" wrote in message ... Hi Danny Thanks for the response but I tried this and am still getting values in some fields. I have clculated fields which are updated depending on avlues entered in boud fields. What is hapenning is that when I try to create a new record the calculated values in teh previous record are being carried into the new record, in other words instead of displaying the default value 0 I am getting whatever figure was in the previous record. You could always do the calculations in the form's query. You could use either the "Iif" function or write your own (similar to the code you already have) and pass the fields from the query to it as arguments. Keith. www.keithwilby.co.uk |
Thread Tools | |
Display Modes | |
|
|