Referencing fields

D

David Pellegrino

I have a project for work in which I am trying to create a
database to put student information in. In the process I
have hit a snag. I have a table named "Renewable
Certification" and in that table there is a field
called "CPR Cert". What I want to do is say that a second
field "CPR Cert Expiration"="CPR Cert" + 1 year. I am
trying to enter this in the default value in design view
using the dateadd function but I have been unsuccessful at
referencing it. If I could tackle referencing other cells
then I could do a vast array of more powerful functions
for this database, such as automatically calculating
expiration dates and checking against todays date for
expiration. If someone could help me out with referencing
fields in access I would greatly appreciate it. Please
email me if you know more about this. Thank you.
 
J

John Vinson

I have a project for work in which I am trying to create a
database to put student information in. In the process I
have hit a snag. I have a table named "Renewable
Certification" and in that table there is a field
called "CPR Cert". What I want to do is say that a second
field "CPR Cert Expiration"="CPR Cert" + 1 year.

This field SHOULD NOT EXIST. See below.
I am trying to enter this in the default value in design view
using the dateadd function but I have been unsuccessful at
referencing it. If I could tackle referencing other cells
then I could do a vast array of more powerful functions
for this database, such as automatically calculating
expiration dates and checking against todays date for
expiration. If someone could help me out with referencing
fields in access I would greatly appreciate it.

Access IS NOT A SPREADSHEET. Trying to treat it as one is a bad
mistake!

Rather than trying to treat a Table as if it were a spreadsheet (which
it's not), store just the base data in your Table and then create
Queries in which to calculate new data. For instance, you can store
the [CPR Cert] field - or, better, avoid blanks in fieldnames and use
CPR_Cert - in your Table; create a Query based on the table and type

[CPR Cert Expiration]: DateAdd("yyyy", 1, [CPR_Cert])

in a vacant Field cell.
Please email me if you know more about this. Thank you.

Done... but please be aware that this request is considered impolite.
If it's worth my time as a volunteer to come answer questions, it
should be worth yours to come back to the newsgroup for the answer.
Private EMail support is available to my paying customers (I'm a
self-employed consultant); public replies to public messages are free.
 
C

CJ

It's also not a good idea to name tables, fields,
controls, forms, reports, etc. with spaces. It causes
headaches when you must refer to them in code, etc. later
on down the road (as you've discovered). For example,
when naming tables, use "TblCustomer" (no space) or for
naming fields within the table
use, "CustomerID", "CustFName", "CustLName". Otherwise,
if you must later refer to objects that DO include
spaces, you usually have to use parantheses, brackets,
quotes or the underscore, i.e. Forms!CPR_Cert. The help
menu is quite helpful for referencing how to refer to
database objects in code, controls, etc.
 

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