By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,640 Members | 2,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,640 IT Pros & Developers. It's quick & easy.

Access Future Date Query

P: 1
I need to use a dateadd funtion based on values in a table.
E.G 1,2,3,4,5,6,= add 2 years 7,8,9,10,11,12,13,14 ,15 or 19 = ad 3 years 16,17,18 = add 5 years. These are added to an entered date.
I see that to add a date is =DateAdd("y", 2,[txtdate]) but I am looking for a multiple choice function.
Mar 13 '07 #1
Share this Question
Share on Google+
3 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
I need to use a dateadd funtion based on values in a table.
E.G 1,2,3,4,5,6,= add 2 years 7,8,9,10,11,12,13,14 ,15 or 19 = ad 3 years 16,17,18 = add 5 years. These are added to an entered date.
I see that to add a date is =DateAdd("y", 2,[txtdate]) but I am looking for a multiple choice function.
You don't say the name of your field that holds these values or if it is available on your form. Assuming it is on the form and is called txtValue then ...

Expand|Select|Wrap|Line Numbers
  1. =DateAdd("y", [txtValue], [txtdate])
Mary
Mar 13 '07 #2

FireMedic
P: 18
I would suggest using an "If/Then/Else" or a "Select Case" ie.:
Expand|Select|Wrap|Line Numbers
  1. If [tbl_value] is < 7 Then [MyDate] = DateAdd("yyyy",2,[OriginalDate]) 
.

It might be more elegant to declare your interval as a string and use the IF or Select Case to set the value.
Expand|Select|Wrap|Line Numbers
  1. DateAdd("yyyy",MyString,[OriginalDate])
.

I hope I'm not being to vague. It's 0530 at the tail end of a night shift for me.
Good Luck
Hope it's of some help.
Mar 13 '07 #3

NeoPa
Expert Mod 15k+
P: 31,495
I need to use a dateadd funtion based on values in a table.
E.G 1,2,3,4,5,6,= add 2 years 7,8,9,10,11,12,13,14 ,15 or 19 = ad 3 years 16,17,18 = add 5 years. These are added to an entered date.
I see that to add a date is =DateAdd("y", 2,[txtdate]) but I am looking for a multiple choice function.
You could use Choose() :
Expand|Select|Wrap|Line Numbers
  1. =DateAdd("y",Choose([DJSValue],2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,5,5,5,3),[txtDate])
Mar 15 '07 #4

Post your reply

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