Auto populate Dates in Access Forms based on a yes or no statement

M

Mchipser

Is there a way to autopopulate a date based on a yes or no selection?

I am practicing building a databse and building a video rental store..

I want to place a "due date" based on if it is a new-relase or a non
new-release.

so if the customer rents a "new release" I want the due date to be =Date()+2
but if is a old movie =Date()+3 or more..

Is there a way to do this??
 
T

tina

in the data entry form, add code to the "new release" field's AfterUpdate
event procedure, something along the lines of

Select Case Me!NewReleaseControlName
Case "Yes"
Me!DueDateControlName = Date + 2
Case "No"
Me!DueDateControlName = Date + 3
Case Else
Me!DueDateControlName = Null
End Select

read up on the Select Case statement, so you'll understand how it works.

hth
 
T

Tom van Stiphout

On Thu, 13 Nov 2008 19:22:45 -0800, Mchipser

=DateAdd("d",Date(), IIf(MyCheckbox=True, 3, 2))

So we check MyCheckbox, and if it is checked we add 3, otherwise 2.
Note that DateAdd is better than Date+x, because who's to say this
would add days, not seconds or years?
IIf is the "immediate if" function - see help file.

-Tom.
Microsoft Access MVP
 
T

tina

Note that DateAdd is better than Date+x, because who's to say this
would add days, not seconds or years?

my understanding of dates is that they are actually stored as Double number
values, where the whole number is a count of days and the decimal value is a
fraction of a whole day. if that's correct, wouldn't adding a whole number x
to the count of days increase that count by the same x whole days? did i
miss the boat on this? tia, tina
 

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