DateAdd Frustrations!!!! Please Help!!!!

S

spcscooter

I really hope that some one can help. I have tried using a Query and a form
in Access 2003 and here is the expression:

=DateAdd("d",120,[StartDate]) This Expression has been added to the
DefaultValue property

What I am trying to do is add 120 days to the StartDate field in a form to
give me the date 120 days after the date I enter into the StartDate field for
a PromotionDeadline field. Here is what the form looks like:

EmployeeID HireDate StartDate End Date PromotionDeadline
12345 12/01/06 12/22/06 12/29/06 (And here is
where I want the date to automatically fill in once I input the StartDate.)

Now I have tried to do this in a Query also and no luck. I would like to
accomplish in the form if at all possible. If not can some one help me so I
don't melt my brain anymore than I have. Please!!!!!

s.rawlings[AT]comcast[DOT]net
 
J

John Vinson

I really hope that some one can help. I have tried using a Query and a form
in Access 2003 and here is the expression:

=DateAdd("d",120,[StartDate]) This Expression has been added to the
DefaultValue property

What I am trying to do is add 120 days to the StartDate field in a form to
give me the date 120 days after the date I enter into the StartDate field for
a PromotionDeadline field. Here is what the form looks like:

EmployeeID HireDate StartDate End Date PromotionDeadline
12345 12/01/06 12/22/06 12/29/06 (And here is
where I want the date to automatically fill in once I input the StartDate.)

Now I have tried to do this in a Query also and no luck. I would like to
accomplish in the form if at all possible. If not can some one help me so I
don't melt my brain anymore than I have. Please!!!!!

s.rawlings[AT]comcast[DOT]net

First suggestion: use that expression as the ControlSource of
PromotionDeadline, rather than its DefaultValue. The DefaultValue is
applied at the instant the record is created - and at that point
there's nothing IN StartDate.

This assumes that you just want to *see* the date in
PromotionDeadline. If in fact that date is always 120 days after
StartDate, and you never need to be able to edit it and store the
edited value, then you shouldn't have a field in the table for
PromotionDeadline at all: just calculate it as above, when and where
it's needed.

If you *do* want to make exceptions to the 120 day deadline, then you
can use code in the StartDate control's AfterUpdate event. Assuming
that these two fields are bound to textboxes named txtStartDate and
txtPromotionDeadline, you can select txtStartDate; view its
properties; click the ... icon by the AfterUpdate property; and edit
it to

Private Sub txtStartDate_AfterUpdate()
If IsDate(Me.txtStartDate) Then
Me.txtPromotionDeadline = DateAdd("d", 120, Me.txtStartDate)
End If
End Sub

John W. Vinson[MVP]
 
S

spcscooter via AccessMonster.com

You are a God.

Thank you very much.
I really hope that some one can help. I have tried using a Query and a form
in Access 2003 and here is the expression:

=DateAdd("d",120,[StartDate]) This Expression has been added to the
DefaultValue property

What I am trying to do is add 120 days to the StartDate field in a form to
give me the date 120 days after the date I enter into the StartDate field for
a PromotionDeadline field. Here is what the form looks like:

EmployeeID HireDate StartDate End Date PromotionDeadline
12345 12/01/06 12/22/06 12/29/06 (And here is
where I want the date to automatically fill in once I input the StartDate.)

Now I have tried to do this in a Query also and no luck. I would like to
accomplish in the form if at all possible. If not can some one help me so I
don't melt my brain anymore than I have. Please!!!!!

s.rawlings[AT]comcast[DOT]net

--
Scot Rawlings
Technical Trainer
Comcast
Auburn, WA

Message posted via AccessMonster.com
 

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

Similar Threads

Between Dates 1
Date Issues - Help! 3
Lookup in a query 1
Assigning a number to a date range 3
Between Date 10
DateAdd 5
Calculate Percent Return for Stocks 3
Please help with datatype mismatch 8

Top