I see what you mean, Binny, you need to store this value in your table
because if the Insurance rate changes then the calculation would change for
past records as well as future ones.
You are being Good and using a form to enter your data, aren't you Binny?
If you are, then, use the After Update Event of your checkbox ie
In the Form's Design View, Click on Properties, Click on your checkbox,
click on the Events tab of Properties.
Click next to After Update.
Choose Event Procedure, click just right of that to open a Code page.
Above the words End Sub, type in
If Me.[Insurance] = True Then
Me.[MyRateField] = 7.5
End if
Because it is in the AfterUpdate Event of the Checkbox, it occurs whenever
the checkbox is updated with a tick.
Change the names, Insurance and MyRateField to the real name of your
controls.
There are a number of refinements you may want to consider.
Do you want this 7.5 to be entered only if you are entering a new record?
Do you want the 7.5 to be removed if you untick the checkbox.
Most importantly, it isn't usually a good idea to enter data (7.5) in code.
You may want to consider creating a table (TblInsuranceRate) which contains
only the current rate and then have the code say
If Me.[Insurance] = True Then
Me.[MyRateField] = DLookup("[InsuranceRate]","TblInsuranceRate")
End if
This makes it easier for you (or another user) to change that field.
Evi
binny said:
Hi CJ
this might sound silly how do you make a calulated field in a table
the only reference I can find is in a query
--
binny
:
Hi Binny:
You need to use an IIF function in a query.
Let's say your check box is named Insurance. You would create a calculated
field whose formula might look like this:
InsuranceRate: IIf([Insurance]=True,7.50,0))
--
HTH
CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!
how do I enter a value into field using a check box
if the insurance check box is checked I want to enter $7.50 into the
insurance field
if the box is not checked I want the field to have the default
value
of 0