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
|
|||
|
|||
check box
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 -- binny |
#2
|
|||
|
|||
check box
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! "binny" wrote in message ... 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 -- binny |
#3
|
|||
|
|||
check box
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 "CJ" wrote: 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! "binny" wrote in message ... 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 -- binny |
#4
|
|||
|
|||
check box
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" wrote in message ... 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 "CJ" wrote: 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! "binny" wrote in message ... 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 -- binny |
#5
|
|||
|
|||
check box
thanks I had a feeling VBA code would be involved Access certainly is limited
with out VBA Putting the insurance rate in another table with an adjustment form is a good idea, your right it changes all the time. -- binny "Evi" wrote: 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" wrote in message ... 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 "CJ" wrote: 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! "binny" wrote in message ... 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 -- binny |
#6
|
|||
|
|||
check box
Don't feel uneasy about using VBA, Binny. It actually makes more sense than
you would think In fact, you will eventually get to the stage where you find Excel annoying because its VBA is so limited. If you are unsure about any of the stages of using it, please say so and we can step you through it. Supply your exact InsuranceRate Table name (if you decide to use one) and field names if you are still unsure about how to edit the code I wrote below and I will put them into the code so that you can see them in situe Evi "binny" wrote in message ... thanks I had a feeling VBA code would be involved Access certainly is limited with out VBA Putting the insurance rate in another table with an adjustment form is a good idea, your right it changes all the time. -- binny "Evi" wrote: 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" wrote in message ... 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 "CJ" wrote: 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! "binny" wrote in message ... 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 -- binny |
Thread Tools | |
Display Modes | |
|
|