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

  • Thread starter Thread starter Mchipser
  • Start date Start date
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??
 
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
 
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
 
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
 
Back
Top