DataPart function

G

Guest

I am trying to extract the month out of the date stored in a field called
AppointmentDate using the DatePart function. The table I am doing this in is
called AppointmentTbl. The field I am extracting it to is called
AppointmentMonth, so I am putting the following in the default value option
of AppointmentMonth:

DatePart("m",[AppointmentDate])

but when I save get the error message "The database engine does not
recognize either the field "AppointmentDate" in a validation expression, or
the default value in the table "AppointmentTbl"."

After I got this message I changed the expression so I put Now() instead of
[AppointmentDate] and the table saved ok. So I don't think its a problem with
table or the expression - must be something to do with [AppointmentDate]??? I
have tried shorter field names but this hasn't worked either.

I am using Access 2002.

Any help greatfully received.

Thanks
 
G

Guest

Thanks for the reply.

Jeff C said:
When I want the month I use:

AppointmentMonth:Format([AppointmentDate],"mmmm")
--
Jeff C
Live Well .. Be Happy In All You Do


clueless_steve said:
I am trying to extract the month out of the date stored in a field called
AppointmentDate using the DatePart function. The table I am doing this in is
called AppointmentTbl. The field I am extracting it to is called
AppointmentMonth, so I am putting the following in the default value option
of AppointmentMonth:

DatePart("m",[AppointmentDate])

but when I save get the error message "The database engine does not
recognize either the field "AppointmentDate" in a validation expression, or
the default value in the table "AppointmentTbl"."

After I got this message I changed the expression so I put Now() instead of
[AppointmentDate] and the table saved ok. So I don't think its a problem with
table or the expression - must be something to do with [AppointmentDate]??? I
have tried shorter field names but this hasn't worked either.

I am using Access 2002.

Any help greatfully received.

Thanks
 
G

Guest

Cheers for tip

Allen Browne said:
Steve, see:
Calculated fields
at:
http://allenbrowne.com/casu-14.html

The article explains how to do this in a query, instead of storing the month
field in the table where the data can go wrong.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

clueless_steve said:
I am trying to extract the month out of the date stored in a field called
AppointmentDate using the DatePart function. The table I am doing this in
is
called AppointmentTbl. The field I am extracting it to is called
AppointmentMonth, so I am putting the following in the default value
option
of AppointmentMonth:

DatePart("m",[AppointmentDate])

but when I save get the error message "The database engine does not
recognize either the field "AppointmentDate" in a validation expression,
or
the default value in the table "AppointmentTbl"."

After I got this message I changed the expression so I put Now() instead
of
[AppointmentDate] and the table saved ok. So I don't think its a problem
with
table or the expression - must be something to do with
[AppointmentDate]??? I
have tried shorter field names but this hasn't worked either.

I am using Access 2002.

Any help greatfully received.

Thanks
 

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