Can I calculate fields in Access like in Excel

D

Dave Nelson

I have a database where I would like one field to be the result of another
field. I can do this easily in Excel, I have tried to find it in Access
help, to no avail.

For example in Excel:
=month(C1) would be a formula to return the value of the month where c1 was
a date value.

Thanks,
Dave
 
D

Douglas J. Steele

What you're trying to do is a violation of database normalization principles
(having one field strictly dependent on the value of another field in the
same row), so Access doesn't support it.

What you can do is create a query, and put your calculated field in the
query. Once you've done that, use the query wherever you would otherwise
have used the table.
 
J

John Vinson

I have a database where I would like one field to be the result of another
field. I can do this easily in Excel, I have tried to find it in Access
help, to no avail.

For example in Excel:
=month(C1) would be a formula to return the value of the month where c1 was
a date value.

Excel is a spreadsheet, a very good one.

Access is a relational database.

THEY ARE DIFFERENT. You can drive nails with a crescent wrench, but
that doesn't make it a hammer!

Stop, step back, and prepare to do a fairly significant mental
reorientation. Read up about "Database Design" and "Normalization",
and plan to use Access as it is designed.

The direct answer to your question is that you can't and shouldn't do
this in a Table, but it's perfectly easy in a Query; simply create a
Query based on your table and type

ShowMonth: Month([datefield])

in a vacant Field cell. When you open this query as a datasheet, or
(better) open a Form or Report based on the query, you'll see the
month number.
 

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