473,511 Members | 14,799 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 4936
NeoPa
32,557 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,557 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,557 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,557 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
NeoPa
32,557 Recognized Expert Moderator MVP
You're right. Tim did start with a ComboBox rather than a TextBox control. Also, if there really is just a limited list of possible values, then a single ComboBox would be more appropriate. Separating them out would only be called for, for a large or unlimited number of possible values.
Nov 19 '10 #11
Tim Mullin
48 New Member
I do have the number of month choices set specifically in a combo box, however the resulting end date is too important with what we do to not have it stored, so I've gone ahead and removed the "auto-generate" function.

Numerous queries that use the end date as some sort of parameter that we need won't work (without more intense behind the scenes coding), so I think I'm going to leave it as a manual entry.

Thanks to everyone that replied, I really appreciate it!
Nov 23 '10 #12
Tim Mullin
48 New Member
Actually I take that back... I simply replaced the EndDate column headers in each of the queries with

Expand|Select|Wrap|Line Numbers
  1. EndDate: DateAdd('m',[Term],[StartDate])
and now they all work perfectly. Obviously as mentioned above having the data like this isn't the best way of doing it, however I feel that this is the best way to prevent the great deal of potential human error that could arise from manually computing the end date.

Thanks again guys!
Nov 23 '10 #13
NeoPa
32,557 Recognized Expert Moderator MVP
Tim Mullin:
Obviously as mentioned above having the data like this isn't the best way of doing it,
obviously doesn't really work in this context. In fact the statement is wholly insupportable. Not only is that way the best way of doing it, it is also the only way that makes sense, unless all the brains that worked on the concepts of database normalisation are wrong and don't know what they're talking about. I won't be putting any money on that one ;-)
Nov 24 '10 #14

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

Similar topics

2
6279
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...
16
41586
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...
16
2067
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...
8
14190
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...
3
3093
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...
3
11702
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...
5
2221
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. ...
1
2013
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...
17
2753
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...
0
857
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
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7371
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
7093
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
7517
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
5676
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,...
1
5077
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...
0
3230
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...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
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.