?
Solved

Access VBA

Posted on 2013-12-17
2
Medium Priority
?
236 Views
Last Modified: 2013-12-17
I have to fields, EndDate and StartDate. I want StartDate to be updated with the beginning of the month 18 months prior to the date I enter in EndDate. How do I do that?

This is my current code, which returns 30-Mar-12 if I enter 30-Sep-13. I would like to have 1-Mar-12 returned


Private Sub EndDate_LostFocus()

StartDate.Value = DateAdd("m", -18, [EndDate].Value)

End Sub
Private Sub EndDate_LostFocus()

StartDate.Value = DateAdd("m", -18, [EndDate].Value)

End Sub

Open in new window

0
Comment
Question by:fitaliano
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 1000 total points
ID: 39723924
Hi

pls try

DateSerial(Year(DateAdd("m", -18, [EndDate].Value)), Month(DateAdd("m", -18, [EndDate].Value)), 1)

Regards
0
 
LVL 48

Assisted Solution

by:Dale Fye
Dale Fye earned 1000 total points
ID: 39723932
How about:

StartDate.Value = DateSerial(Year([EndDate].Value), Month([EndDate].value) - 18, 1)
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

800 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