Link to home
Start Free TrialLog in
Avatar of Cyprexx IT
Cyprexx IT

asked on

Add days to date

I'm trying to figure out how to add days to a date in vba..

it cannot exclude weekends and holidays, it must count +17 complete days.\

thanks
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image


  dateadd("d", 17, [DateField])

to add 17 days to todays date

  dateadd("d", 17, Date())
you can also do this  
     date() +17
Avatar of Cyprexx IT
Cyprexx IT

ASKER

I mean like, when I click on text field AuctionDate I want it to take PublishedDate field and add +17 days and display it in AuctionDate field.


Private Sub AuctionDate_Click()
Me.PublishedDate = DateAdd("d", 17, [AuctionDate])
Me.Recalc
End Sub


Trying to accomplish that



Private Sub AuctionDate_Click()
Me.AuctionDate = DateAdd("d", 17, [PublishedDate])
Me.Recalc
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Generally calculated values like that shouldn't be stored in your tables. It creates redundant data, and can complicate things if a field that the calculation is based on changes.

With that understood, if you use this in the control source property of your AuctionDate textbox, it will display the value, and automatically change if PublishedDate changes:

= DateAdd("d", 17, [PublishedDate])

(Include the = sign in your control source)