Calculating future dates in Access

S

S. Roberts

I am trying to set the "default value" for a date field in an Access Database. I would like the date to be set two weeks in the future, but the day of the week should always be "Wednesday". Any suggestions?
 
K

Ken Snell

Try this as the Default Value expression (assuming that you always "round
up" to the next week if the current day of the week is Thursday, etc.):

=DateAdd("d", 21 - DatePart("w", Date(), vbThursday), Date())

--
Ken Snell
<MS ACCESS MVP>


S. Roberts said:
I am trying to set the "default value" for a date field in an Access
Database. I would like the date to be set two weeks in the future, but the
day of the week should always be "Wednesday". Any suggestions?
 
S

S. roberts

I tried out your suggestion but it keeps giving me the word "Error" in form view for the field where I set the default value. When I typed in your formula I typed in the "vbThursday" phrase (without quotation marks). When I went back to it later, Access had placed quotation marks around that phrase.

----- Ken Snell wrote: -----

Try this as the Default Value expression (assuming that you always "round
up" to the next week if the current day of the week is Thursday, etc.):

=DateAdd("d", 21 - DatePart("w", Date(), vbThursday), Date())

--
Ken Snell
<MS ACCESS MVP>


S. Roberts said:
I am trying to set the "default value" for a date field in an Access
Database. I would like the date to be set two weeks in the future, but the
day of the week should always be "Wednesday". Any suggestions?
 
K

Ken Snell

Ah, I keep forgetting that the VBA intrinsic constants don't work in the
properties of a control on a form.

Replace vbThursday with the number 5.

--
Ken Snell
<MS ACCESS MVP>

S. roberts said:
I tried out your suggestion but it keeps giving me the word "Error" in
form view for the field where I set the default value. When I typed in your
formula I typed in the "vbThursday" phrase (without quotation marks). When
I went back to it later, Access had placed quotation marks around that
phrase.
 

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