Prompt For Date In A Report

C

charles.kendricks

I have a report with two unbount text boxes text0 and text2. I want to
be able to prompt the user for a date in text0 and have text2
automatically display the date one day later. When I place
"=Date()" in text0 and "=[text0] + 1" in text2 everything works fine.
However when I place "[Enter Date]" in text0 I get errors....What am I
overlooking?
 
F

fredg

I have a report with two unbount text boxes text0 and text2. I want to
be able to prompt the user for a date in text0 and have text2
automatically display the date one day later. When I place
"=Date()" in text0 and "=[text0] + 1" in text2 everything works fine.
However when I place "[Enter Date]" in text0 I get errors....What am I
overlooking?

If the [Text0] control source is =Date() then Access knows the value
is a date datatype therefore =[Text0]+1 will add 1 day to the value
and correctly display a date (the next day).

If =[Enter Date] is the Text0 control source, Access has no idea what
the datatype is of the value you enter, so it assumes Variant.
A value of 4/15/2006 +1 is therefore meaningless as the Text2 control
source.

Try:
as Text0 control source:
=[Enter Date]
as Text2 Control Source:
=CDate([Text0])+1

You can also use, as the Text2 control source:
=CDate([Enter Date])+1

Also be aware [Text0] is a Variant value, not a date value. You cannot
perform any date functions with it, unless you also first convert it
to a date, i.e. =CDate([Enter Date])
 

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