Autofill a Date

C

Crystal T

I'm creating a form and I want to know if you can Autofill my "Date of Quote"
with the current date and then have my "Valid Through" be +30 days of the
date of quote. Any help would be appreciated.

Thanks Bunches!!!
 
D

Douglas J. Steele

Set the default for the Date of Quote field to Date(). You shouldn't be
storing the ValidThrough field in your table (since you can calculate it
anytime you need it), so you can set its ControlSource to =DateAdd("d", 30,
Date())
 
C

Carl Rapson

Crystal T said:
I'm creating a form and I want to know if you can Autofill my "Date of
Quote"
with the current date and then have my "Valid Through" be +30 days of the
date of quote. Any help would be appreciated.

Thanks Bunches!!!

Sure. In the Form_Current event, add code something like:

Me.[Date of Quote] = Date
Me.[Valid Through] = DateAdd("d", 30, Me.[Date of Quote])

In case the user manually changes the [Date of Quote] value, you'll also
want to put the second line into the AfterUpdate event of the [Date of
Quote] control also.

Carl Rapson
 
M

Mr. B

Crystal T said:
I'm creating a form and I want to know if you can Autofill my "Date of
Quote"
with the current date and then have my "Valid Through" be +30 days of the
date of quote. Any help would be appreciated.
Thanks Bunches!!!

Sure. In the Form_Current event, add code something like:

Me.[Date of Quote] = Date
Me.[Valid Through] = DateAdd("d", 30, Me.[Date of Quote])

In case the user manually changes the [Date of Quote] value, you'll also
want to put the second line into the AfterUpdate event of the [Date of
Quote] control also.

Carl Rapson

Try using Doug's method and locking both the Date of Quote control and
the Valid Through control as well. This way your users cannot change
those dates.

Mr. B
 
C

Crystal T

Thanks to all of you your answers were really helpful.

Mr. B said:
Crystal T said:
I'm creating a form and I want to know if you can Autofill my "Date of
Quote"
with the current date and then have my "Valid Through" be +30 days of the
date of quote. Any help would be appreciated.
Thanks Bunches!!!

Sure. In the Form_Current event, add code something like:

Me.[Date of Quote] = Date
Me.[Valid Through] = DateAdd("d", 30, Me.[Date of Quote])

In case the user manually changes the [Date of Quote] value, you'll also
want to put the second line into the AfterUpdate event of the [Date of
Quote] control also.

Carl Rapson

Try using Doug's method and locking both the Date of Quote control and
the Valid Through control as well. This way your users cannot change
those dates.

Mr. B
 
J

John W. Vinson

Crystal T said:
I'm creating a form and I want to know if you can Autofill my "Date of
Quote"
with the current date and then have my "Valid Through" be +30 days of the
date of quote. Any help would be appreciated.

Thanks Bunches!!!

Sure. In the Form_Current event, add code something like:

Me.[Date of Quote] = Date
Me.[Valid Through] = DateAdd("d", 30, Me.[Date of Quote])

In case the user manually changes the [Date of Quote] value, you'll also
want to put the second line into the AfterUpdate event of the [Date of
Quote] control also.

Karl, wouldn't this reset the date of quote and the valid through date any
time the user *views* the record? I suspect that the Current event is too
"hair trigger" for what Crystal wants!

John W. Vinson [MVP]
 
M

Mr B

Crystal,

John is correct as usual.

You can still use the same code in the same event, just wrapper it like:

If Not IsNull(Me.[Date of Quote]
Me.[Date of Quote] = Date
Me.[Valid Through] = DateAdd("d", 30, Me.[Date of Quote])
end if

That should do it.

--
HTH

Mr B
email if needed to:
draccess at askdoctoraccess dot com


John W. Vinson said:
Crystal T said:
I'm creating a form and I want to know if you can Autofill my "Date of
Quote"
with the current date and then have my "Valid Through" be +30 days of the
date of quote. Any help would be appreciated.

Thanks Bunches!!!

Sure. In the Form_Current event, add code something like:

Me.[Date of Quote] = Date
Me.[Valid Through] = DateAdd("d", 30, Me.[Date of Quote])

In case the user manually changes the [Date of Quote] value, you'll also
want to put the second line into the AfterUpdate event of the [Date of
Quote] control also.

Karl, wouldn't this reset the date of quote and the valid through date any
time the user *views* the record? I suspect that the Current event is too
"hair trigger" for what Crystal wants!

John W. Vinson [MVP]
 
Top