Jump to content
N-Europe

MS Access: Can I use a calculated field in a queries criteria?


Recommended Posts

Posted (edited)

Ok basically I am just making a quick query, it's going to search for a different value depending on age. I don't have an age field in my sources, so I created a calulated field that would figure out a person's Age(from DoB). This is in my query as;

Age: (Date()-([DoB]))/365.25

 

I have another field in my query that I want the query to essentially run off, but I want its criteria to depend on age. Basically >0.8 if Age>=65, >1.0 if else. I thought an IIf statement would be fine;

 

>IIf([Age]>=65,0.8,1)

 

BUT! This is where my problem strikes. Can I/how do I refer to the new calculated field 'Age' in the criteria box without it trying to ask me for the criteria. If that makes sense. If i type it as above a popup prompt appears asking for age. I'm quite new to dabbling in access like this, and not even sure if it's possible. I'm in Access's query builder, as I know no SQL. Maybe this is an SQL job...

Edited by Rummy
×
×
  • Create New...