Solved

access 2010 vba calculate dates

Posted on 2014-04-24
4
641 Views
Last Modified: 2014-04-24
Hi,

I have a query regarding using vba to calculate due dates.

Overview:
i have a form where the user enters an start date for a contract. What i need to do is, after the start date has been entered, auto calculate 2 different dates based upon the month of the start date.

i.e. if the start date entered is any day in January, for example 05/01/2014, then due date to be calculated should be 01/03/2014, settlement date to be calculated should be 31/03/2014.

Start Date                Due Date             Settlement Date
any day in Jan           01/03/2014          31/03/2014
any day in Feb          01/04/2014          30/04/2014
etc etc

Many thanks
0
Comment
Question by:andrewpiconnect
  • 2
4 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 250 total points
ID: 40019565
DueDate = DateSerial(Year([StartDate]), Month([StartDate]) + 2, 1)

SettlementDate = DateSerial(Year([StartDate]), Month([StartDate]) + 4, 0)
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 250 total points
ID: 40019790
SettlementDate exceeds by a month

should be
SettlementDate = DateSerial(Year([StartDate]), Month([StartDate]) + 3, 0)
0
 

Author Closing Comment

by:andrewpiconnect
ID: 40019884
Thanks Guys....works a treat
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40020032
Thanks for catching that Rey, I hate dd/mm/yy format!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now