473,803 Members | 3,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is it possible to generate an "end date" after entering start date and term length?

48 New Member
Hello all,

I'm hoping to find an answer to a question I have using forms in Access 2007.

I have a form (source: table) that has three fields:

Start Date
Term (number of months)
End Date

Currently the user has to enter a start date, select a term from a drop down combo box, and then enter an end date. Is it possible to have it set up where after the term is selected in the combo box the end date is automatically generated?

Any help would be greatly appreciated! thanks!
Oct 29 '10 #1
13 4958
NeoPa
32,579 Recognized Expert Moderator MVP
This is perfectly possible, but the idea of storing values that are calculable from existing data is not good (See Database Normalisation and Table structures for more).

The code to achieve this is :
Expand|Select|Wrap|Line Numbers
  1. DateAdd('m', [Term], [Start Date])
Oct 29 '10 #2
Tim Mullin
48 New Member
Is there a certain way I should format the input for the start date or for the term in the combo box? The current format is:

Start Date

Data Type: Date/Time
Input Mask: 00/00/"20"00;;_

Term

Data Type: Text
lookup box with the terms manually entered, not linked to another table (e.g. "1 month", "3 months", "12 months" and so on...)

when i pasted your code into the control source for the end date field it returned "#ERROR" in the field, but I'm assuming there is something wrong with the two fields mentioned above.

thanks again!
Oct 29 '10 #3
NeoPa
32,579 Recognized Expert Moderator MVP
Tim, if you need a numeric value there - store a numeric value. You can probably extract a numeric value from the strings if you know exactly how they're formatted, but I can't as you haven't shared enough information with your three example values.

PS. The date as a date is fine and exactly as expected.
Oct 29 '10 #4
Tim Mullin
48 New Member
I got it to work! Obviously though there are issues with the data being stored, which you pointed out. I'm assuming there is no way to have it store that data?
Nov 12 '10 #5
NeoPa
32,579 Recognized Expert Moderator MVP
There is nothing to stop you storing the data, except the understanding that it will not help you, and will likely involve you in extra complications. There will be no benefit from it for you.

I'm sorry. I guess that's not what you want to hear, but it's truth so I have to say it.
Nov 13 '10 #6
Tim Mullin
48 New Member
No worries, I came across this issue earlier in the database but figured I would ask again...

Thanks again for the help!
Nov 16 '10 #7
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
I would HIGHLY recommend changed your term text box to a combobox, in which the user can select a number of months. Having users manually typing things where precision is required is always a bad idea.
While it may be easy to write code to parse values such as "3 months" you will run into problems when you have users typing stuff such as "3", "3 mnths","3-6 months","3½ months","7mngts " and so on.
Nov 17 '10 #8
NeoPa
32,579 Recognized Expert Moderator MVP
That's a good idea Smiley. I'd take it a step further though, and separate the value out from the units. It can be stored as a single text field if required, but the ComboBox would be better off simply allowing the selection of the units without any numerical values included.

Good thinking :-)
Nov 17 '10 #9
colintis
255 Contributor
As from the example Tim provided earlier, there should be a fixed amount of choices for the term. If so, its better off to make selection with a combo box or option radio buttons.
Nov 19 '10 #10

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

Similar topics

2
6320
by: dmiller23462 | last post by:
Hey guys, I'm back again....I've got the results displaying that I wanted but instead of having a "next" or "previous" link displayed I am getting the error msg below (I actually get the data that I'm supposed to get meaning that my query seems to be working fine but instead of making its way to the INCLUDE file (bottom navigation bar) it displays the following error msg instead of the included nav bar... *** error '80020009' Exception...
16
41639
by: sandy | last post by:
Hi, Using Java script I am trying to create code where when you place in the start date it automatically calculates 6 months for the experations date. For example when I place 01/01/04 as the issue date the experation date should automaically generate as 06/01/04. I would appreciate it if anyone could help me. Thank you Sandy
16
2109
by: WindAndWaves | last post by:
Hi there I have $initstartdate = date("d-m-Y"); in my code How can I get it to be date() + 1 or 7 for that matter. Because my server is in the US and I am in New Zealand, they are always a day behind....
8
14208
by: Paul T. Rong | last post by:
I used "between and " in a query as a criteria to a field called ShipDate. Very strange, in the case between 1.10.2003 and 31.10.2003, then the records from 31.10.2003 don't show up. I have to modify it as between 1.10.2003 and 1.11.2003 for the records from 31.10.2003 show up. anybody had same problem? I check the Access Help but didn't get any clue. Thanks in advance
3
3123
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my working week definition. Lets say I have a working week definition of Monday through Friday, 9 am to 5 pm. Date1 = January 1st, 2005 at 8 am
3
11737
by: Reney | last post by:
I am using Access Database in my program. The column in the table that I am going to use has date/time value with Medium Time selected. (HH:mm). The program is recording a clock in time to this field, which is the time when the entry is made. If you check the database, it shows the correct time in the correct format. But when you are calling it with a dataset and showing with a datagrid, it doesn't show the time value but it always shows...
5
2231
by: martin DH | last post by:
Morning, Here's my problem: I have a field (ResFileLocation) on a form (frmResolution) that inserts a record-specific value (record ID, date stamp, etc) through vba when it has gained focus. To help clarify, here is the basic code I am looking at: Private Sub ResFileLocation_GotFocus() Me!ResFileLocation = "Forms!!NoticeID & "R_" & Left(Date, 2) & Mid(Date, 4, 2) & Right(Date, 4) End Sub
1
2028
by: perlvasu | last post by:
6 jobs are running at the same time and accessing same dbm file for writing and reading. These are daily jobs and failing only some times not regularly. So i thought of this is just because of dead lock situation. So i tried to put flock here in the following code. But i got the following error. Can't locate object method "fd" via package "SDBM_File" Can any body help me in this case. use strict ; use warnings ; use SDBM_File ;
17
2789
by: David C. Ullrich | last post by:
Having a hard time phrasing this in the form of a question... The other day I saw a thread where someone asked about overrideable properties and nobody offered the advice that properties are Bad. So maybe we've got over that. I suppose properties could have Bad consequences if a user doesn't know they exist and think that a certain property of an object is just an ordinary attribute. But that applies to
0
869
by: bruce | last post by:
Hi. a pretty simple question, i'm guessing. i have a text/html string that looks like: ....(A&E) the issue i have is that when i parse it using xpath/node/toString, i get the following
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5501
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4275
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 we have to send another system
3
2972
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.