Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Auto populate Dates in Access Forms based on a yes or no statement

Geek News

Auto populate Dates in Access Forms based on a yes or no statement
Mchipser 11/14/2008 3:22:45 AM
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??

Re: Auto populate Dates in Access Forms based on a yes or no statement
"tina" <nospam[ at ]address.com> 11/14/2008 3:42:09 AM
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


"Mchipser" <Mchipser[ at ]discussions.microsoft.com> wrote in message
news:0A94386B-758C-46C4-A6C3-686D298D8A0B[ at ]microsoft.com...
[Quoted Text]
> 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??
>


Re: Auto populate Dates in Access Forms based on a yes or no statement
Tom van Stiphout <tom7744.no.spam[ at ]cox.net> 11/14/2008 3:56:31 AM
On Thu, 13 Nov 2008 19:22:45 -0800, Mchipser
<Mchipser[ at ]discussions.microsoft.com> wrote:

=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



[Quoted Text]
>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??
Re: Auto populate Dates in Access Forms based on a yes or no statement
"tina" <nospam[ at ]address.com> 11/14/2008 4:20:14 AM
[Quoted Text]
> 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


"Tom van Stiphout" <tom7744.no.spam[ at ]cox.net> wrote in message
news:nitph4tboishkodr43e405lss39bbisonv[ at ]4ax.com...
> On Thu, 13 Nov 2008 19:22:45 -0800, Mchipser
> <Mchipser[ at ]discussions.microsoft.com> wrote:
>
> =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
>
>
>
> >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??


Re: Auto populate Dates in Access Forms based on a yes or no statement
Tom van Stiphout <tom7744.no.spam[ at ]cox.net> 11/14/2008 4:42:57 AM
On Fri, 14 Nov 2008 04:20:14 GMT, "tina" <nospam[ at ]address.com> wrote:

It does indeed work like that. Still, I like to be explicit.

-Tom.


[Quoted Text]
>> 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
>
>
>"Tom van Stiphout" <tom7744.no.spam[ at ]cox.net> wrote in message
>news:nitph4tboishkodr43e405lss39bbisonv[ at ]4ax.com...
>> On Thu, 13 Nov 2008 19:22:45 -0800, Mchipser
>> <Mchipser[ at ]discussions.microsoft.com> wrote:
>>
>> =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
>>
>>
>>
>> >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??
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net