check box

C

Carol Shu

hi all,
how can I do this?
have a DB for Vehicles, if I enter the "year" is 10 years old or order, the
check box "EXEMPT" will automaticaly checked. ex: enter year 1996, the check
box "EXEMPT" will checked by it self. thankx
 
A

Al Campagna

Carol,
You really shouldn't be saving the Exempt status in your table. That
should be a calculated field.

And a rule of thumb is to not save any value that can "derived or
calculated from data you already have saved.
This is similar to Price * Qty = LineTotal. As long as you capture the
Price, and capture the Qty, you can always re-calculate the LineTotal "on
the fly" in any subsequent form, query, or report.

Also...
If the initial status of a new record is "non-exempt" (checkbox =
False)... what happens when another year passes. Some of the "non-exempt"
vehicles will be becoming "exempt", but your original record still indicates
"non-exempt." You'll constantly have to edit that status, as time passes...

Try this.
Let's say your check box is named chkExempt, and your year field is
named YOM (for Year of Manufacture)
In the ControlSource for your checkbox, put this calculation...
=IIf(Year(Date())-[YOM]>=10,True,False)
Now, every time you visit a record, the Exempt status will be calculated
"on the fly", and be correct.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
A

Allen Browne

If this should *always* be exempt for older vechicles (i.e. user should not
be able to override it), there's a very simple solution.

Remove the Exempt field from the table.
Create a query using this table, and type this into the Field row:
Exempt: (Year(Date()) - [Table1].[Year]) >= 10
Save the query, and use it anywhere you would use your table.

Now the field can't go wrong.

If that's not suitable, see:
Calculated fields
at:
http://allenbrowne.com/casu-14.html

BTW, Year is one of the field names that can cause grief in Access. Consider
changing it to BuildYear or something. When designing tables, refer to this
list for the names to avoid:
http://allenbrowne.com/AppIssueBadWord.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top