Stuart McLachlan
stuart at lexacorp.com.pg
Fri May 11 19:14:14 CDT 2012
Actually, it's Saturday, and nearly beer o'clock already :-)
Calculations do not have to be numeric, otherwise, you wouldn't have the option to set the
Type of a Calculated Column to Text and you couldn't use functions like Right$(),Left$() etc
either.
Format$ is a function to convert a numeric value into a specifically formatted string. It is an
enhanced version of CStr(). It has a valid place in many "calculations".
I know I'd much rather use
Format$(EntryDateTime,"YYMMDDHHMMSS")
than
Right$("00" & Year(EntryDateTime), 2) & Right$("00" & Month(EntryDateTime), 2) &
Right$("00" & Day(EntryDateTime), 2) & Right$("00" & Hour(EntryDateTime), 2) &
Right$("00" & Minute(EntryDateTime), 2) & Right$("00" & Second(EntryDateTime), 2)
especially given that there is a limitation on the length of a calculated column expression.
--
Stuart
On 11 May 2012 at 19:27, Susan Harkins wrote:
> >
> > Format$(Product_PK,"0000" & Left$([Product_Descr],4)
> >
> > It threw the helpful error:
> >
> > "The expression Format$(Product_PK,"0000" & Left$([Product_Descr],4)
> > cannot be used in a
> > calculated column"
> >
> > A bit of testing reveals that you can't use Format/Format$ in a calculated
> > field.
> >
>
> ========In all fairness, formatting a value isn't the same as a calculated
> column -- gentlemen, light your arrows!!!!! :) It's Friday, it's after 5:00
> pm and well...
>
> Susan H.
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>