Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date addtions 1

Status
Not open for further replies.

rotschreck

Programmer
Jan 26, 2000
54
CA
If I have a date in a field and I want to automatically enter that date + 14 days into another field, how would I go about doing that? <p> <br><a href=mailto: > </a><br><a href= Eclectic Page</a><br>
 
You need to give us a few more details!<br>
<br>
Do you want to do this in a query?<br>
<br>
Or are you using a form and need this to happen as data is entered? <p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
 
NewDate = DateSerial(Year(Now), Month(Now), Day(Now) + 14) <p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
you could put it in the AfterUpdate property for the field that you're entering data into.<br>
<br>
basically, if both fields are formatted as date fields, the code could be as simple as<br>
<br>
Private Sub OriginalDateField_AfterUpdate()<br>
CalculatedDateField = OriginalDateField +14<br>
end sub<br>
<br>
if you want to only count business days (Mon-Fri) you would have to use something similar to this:<br>
<br>
If Weekday + 14 = 1 Or Weekday + 14 = 7 Then<br>
If Weekday + 3 = 1 Then<br>
CalculatedDatefield = OriginalDateField + 15<br>
End If<br>
If Weekday + 3 = 7 Then<br>
CalculatedDatefield = OriginalDateField + 15<br>
End If<br>
Else<br>
BusDays = RecdDate + 14<br>
End If<br>
<br>
where 'Weekday' is the name of an unbound field on your form that has a control of <br>
=Weekday([OriginalDateField])<br>
<br>
<br>
<p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top