473,385 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to Auto Display Yearly Contract Expiration

Hi!

I would like to ask help on my form here is the question;

I have a textbox bound to Hired Date, how can I display automatically the Contract Expiration by yearly and the Days remaining before the expiration.
For example:
When I entered the Hired Date as 01/31/2002, the Contract Expiration will be displayed automatically on the future date as 01/31/2013 and the remaining days before expiration:___

Thanks for your help in Advance.

Chain
Jun 11 '12 #1
8 2274
TheSmileyCoder
2,322 Expert Mod 2GB
You can use the DateDiff and DataAdd functions.

Lets say your textbox bound to the Hired date is called:
tb_HiredDate

Add 2 more textboxes lets call them tb_Expire and tb_DaysLeft.

In tb_Expire's CONTROLSOURCE you write:
Expand|Select|Wrap|Line Numbers
  1. =dateadd("yyyy";1;tb_HiredDate)
If you do not always have a value for tb_HiredDate I think it may give an error so we can modify the above to look like:
Expand|Select|Wrap|Line Numbers
  1. =IIF(tb_HiredDate is Null;;dateadd("yyyy";1;tb_HiredDate))
Similarly for tb_DaysLeft:
Expand|Select|Wrap|Line Numbers
  1. =IIF(tb_HiredDate is Null;;datediff("d";tb_Expire;Date()))
Jun 11 '12 #2
Hello,

Thanks for the reply sir, however, I have tried the following condition and I got some error with the expression saying that "the expression you entered contained invalid syntax". I changed the semicolon to comma between "1" and I got answer incremented by one year only. What if the data input is 01/31/2002, how will the future expiration by yearly be auto display lets say on 01/31/2013 for a yearly expiration and also by remaining days?

Sorry I am only a begginer on this but your help sure will enhance my skills.
Jun 11 '12 #3
zmbd
5,501 Expert Mod 4TB
go here and take a look at the syntax for dateadd:
http://office.microsoft.com/en-us/ac...001228810.aspx

go here and take a look at the syntax for datediff:
http://office.microsoft.com/en-us/ac...001228811.aspx

Sometimes the MS explanations are not very clear so don't worry if you need to ask for clarification on a point or two.

-z
Jun 11 '12 #4
thanks for the reply, i will read and try the link and we'll get back if there are more clarifications.
Jun 12 '12 #5
Hi!
I have tried the lesson in the link, but i can't get the desired outcome. what if the hired date has different year, I mean the data to fill in in the hired date is flexible (different dates) how can i get the future expiration exactly in the present year? Likewise on the remaining days.

Thanks.
Jun 12 '12 #6
zmbd
5,501 Expert Mod 4TB
chaingangeextreme:

The code that TheSmileyCoder posted in #2 should handle what you're asking... a simple modification based upon those examples and the the syntax information from #4 should have worked.

Please post the code you've tried so far... more than likely it's something small like a missing comma etc...

-z
Jun 12 '12 #7
Hi!
Again just can't get through with the same error. I attached the error in word form.

Thanks.
Attached Files
File Type: doc Date error.doc (169.5 KB, 265 views)
Jun 13 '12 #8
TheSmileyCoder
2,322 Expert Mod 2GB
Now its a bit more complicated so I would write a custom function in VBA to handle it. If you add a new module to your database, and copy/paste the following code into it:
Expand|Select|Wrap|Line Numbers
  1. Public Function CalculateNextExpiry(InputDate As Variant) As Variant
  2.    'I added this to elegantly handle the case of a new record (in which hireddate is null)
  3.       If Nz(InputDate, -1) = -1 Then Exit Function
  4.  
  5.    'Now calculate next hireddate
  6.       Dim DeltaYear As Integer
  7.       DeltaYear = Year(Date) - Year(InputDate)
  8.  
  9.       CalculateNextExpiry = DateAdd("yyyy", DeltaYear, InputDate)
  10.  
  11.    'Has the date passed this year?
  12.       If CalculateNextExpiry < Date Then
  13.          'Add another year
  14.          CalculateNextExpiry = DateAdd("yyyy", 1, CalculateNextExpiry)
  15.       End If
  16. End Function
You can now call the customfunction where you need it, for example you could set the controlsource of your textbox to be:
=CalculateNextExpiry(tb_HiredDate)

For more information on using custom functions see:
http://bytes.com/topic/access/insigh...-access-2003-a
Jun 18 '12 #9

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

Similar topics

3
by: e01osama | last post by:
I am new to java. I inatalled oracle. I need to display some of the data from table. that table is from oracle.I want to know how to get that data in to interface. pls help.
3
by: Meena | last post by:
Hi Every Body, I have created a crystal Report and linked to my vb.net forms and working fine, I added more drill drowns in groups everything fine, but What I need is I am not able to display...
0
by: arunpillai | last post by:
hi guys, My problem is i need to display different html page in content place holder just like how we will be doing in the frames. I have a menu control when ever the menu is clicked the particular...
5
by: Mel | last post by:
Is there a way of displaying the id of the element under the pointer ? Please dont ask why I need it, but I do, i found tools that needs installation that provide the same funcitonality. However,...
1
by: amarready | last post by:
Can any one kindly post a solution. I want to use php to display the domain name typed in by the user. Parse it to display in the desired format. This result will be checked against a database and...
1
by: pyramid36 | last post by:
A national healthcare software client of ours has an urgent need for 2 C++ Developers with SQL Server eexperience for a 4-6 month contract. Overall the consultants should have 5-8 years experience...
11
by: Gilberto | last post by:
Hello I have a table PRODUCT NAMES with fields PRODUCTNAME and COMMODITY, another table called COMMODITY NAMES with the only field COMMODITIES (containing a list of 7 different commodities), and a...
2
by: mirzaali | last post by:
Hi All, I neeed to dispaly the data in html table tag Query :-select comp,total,funds from table1, WHICH WIL RETURN 3-RECORDSETS rs_query(0) rs_query(1) rs_query(2)
1
by: c0l0nelFlagg | last post by:
I need to display a main form with 48 identical subforms. 6 columns with 8 rows. I set up a separate query for each subform, identical in structure and underlying data except the criteria in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.