473,507 Members | 5,257 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help to calculate a time in the future

2 New Member
I would like to create a field that calculates a date that is 39 months from a date I am entering on a form. Once I fill in a date in a field, I would like to have Access calculate the next field which would be 39 months later. What formula would I enter to achieve that effect? Thank you!
Feb 12 '07 #1
4 2107
ADezii
8,834 Recognized Expert Expert
I would like to create a field that calculates a date that is 39 months from a date I am entering on a form. Once I fill in a date in a field, I would like to have Access calculate the next field which would be 39 months later. What formula would I enter to achieve that effect? Thank you!
Assuming the Text Box containing your Date is txtDate, and the New Date will be contained in txtNewDate, then in the AfterUpdate() Event of txtDate type the following code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtDate_AfterUpdate()
  2.     If Not IsDate(Me![txtDate]) Then
  3.        Exit Sub
  4.     Else
  5.        Me![txtNewDate] = DateAdd("m", 39, Me![txtDate])
  6.     End If
  7. End Sub
Feb 12 '07 #2
Michael R
176 New Member
You can also use this in your textbox Control Source:

=DateAdd("m",39,[txtDate])
Feb 12 '07 #3
neilj
2 New Member
Thanks for your Help!
Assuming the Text Box containing your Date is txtDate, and the New Date will be contained in txtNewDate, then in the AfterUpdate() Event of txtDate type the following code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtDate_AfterUpdate()
  2.     If Not IsDate(Me![txtDate]) Then
  3.        Exit Sub
  4.     Else
  5.        Me![txtNewDate] = DateAdd("m", 39, Me![txtDate])
  6.     End If
  7. End Sub
Feb 12 '07 #4
CSmith
12 New Member
I would like to create a field that calculates a date that is 39 months from a date I am entering on a form. Once I fill in a date in a field, I would like to have Access calculate the next field which would be 39 months later. What formula would I enter to achieve that effect? Thank you!

Use the dateadd(). In your query design view, click in the box where the field you want to calculate is and type
=DateAdd("m",+39, [the field name for the date entered])
once you click out of the box you will see
Expr1:=DateAdd("m",+39, [the field name for the date entered])
Just change the word "Expr1:" to whatever you want the column name to be and there you go. Be sure there is a colon between your column name and the equal sign that starts the expression ... good luck
Feb 12 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3095
by: GM | last post by:
Hello. I am starting my 7th week of an intro to programming class and have a problem I have been working on. My instructor said we could look for source code on the internet and use it as long as...
3
1577
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
7
2658
by: Eric Whittaker | last post by:
Hey guys, i am relatively new at this programming thing and am stuck on an assignment here. I'm trying to get the program below to respond to the integer -1 to stop and calculate total. It does,...
9
4333
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
1
1968
by: Dr_Z2A | last post by:
Ok so a couple months ago I wrote a currency converter and never got it to compile (my memorization of syntax sucked then) and I just had the printed out copy lying in a stack of papers. So I...
6
14431
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a...
4
2483
by: John Devlon | last post by:
Hello everyone... Does anyone know if there is easy way to calculate a certain day in the future ? For example: I would like to calculate when the date is 15 days from today .... I've...
2
1333
by: Takeadoe | last post by:
Dear NG, In an earlier post to the group, I was trying to find and easy way to calculate %change estimates between years for a group of variables. My data looks like this: Year County VarA...
1
1527
by: massdeletion101 | last post by:
I'm using Bloodshed Dev-Cpp version 4.9.9.2 (version five beta) as my compiler and IDE, and I am trying to compute pi truncated to the first 15 decimal places, only there is a problem. I am using a...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7029
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.