A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

lookup and calculate



 
 
Thread Tools Display Modes
  #1  
Old June 15th, 2005, 09:32 PM
dchristo
external usenet poster
 
Posts: n/a
Default lookup and calculate

I have a separate table that has the state code, the month, and day
ex.
state timeframe(months) addl days
Alabama 4 0
Colorado 7 30
In my form if the state = Alabama then I need to Calulate a date field and
add the timeframe and additional days
Ex.
07/12/2004 (if state = Colorado, then add the timeframe (7) and the
additional days (30) to equal 03/14/2005

Can you tell me how to accomplish this?
  #2  
Old June 15th, 2005, 09:55 PM
George Nicholson
external usenet poster
 
Posts: n/a
Default

NewDate = DateSerial(Year(OrigDate),
Month(OrigDate)+Dlookup("[Timeframe]","StateTable","[State] = '" &
StateValue & '"), Day(OrigDate) + DLookup("[AddlDays]","StateTable","[State]
= '" & StateValue & '"))

Whe
OrigDate is your "starting" Date
Table called StateTable contains the fields State, Timeframe and
AddlDays
StateValue is the name of the state you want to look up

If OrigDate = 7/12/2004 and StateValue = "Colorado" then
NewDate = DateSerial(Year(OrigDate), Month(OrigDate)+7, Day(OrigDate) +
30)
NewDate = 3/14/2005


HTH,
--
George Nicholson

Remove 'Junk' from return address.


"dchristo" wrote in message
...
I have a separate table that has the state code, the month, and day
ex.
state timeframe(months) addl days
Alabama 4 0
Colorado 7 30
In my form if the state = Alabama then I need to Calulate a date field and
add the timeframe and additional days
Ex.
07/12/2004 (if state = Colorado, then add the timeframe (7) and the
additional days (30) to equal 03/14/2005

Can you tell me how to accomplish this?



  #3  
Old June 15th, 2005, 10:44 PM
Klatuu
external usenet poster
 
Posts: n/a
Default

You just need the DateAdd function:
Add the Months:
CurrentDate = DateAdd("m",[timeframe],CurrentDate)
Add the Days:
CurrentDate = DateAdd("d",[addl days],CurrentDate)

"dchristo" wrote:

I have a separate table that has the state code, the month, and day
ex.
state timeframe(months) addl days
Alabama 4 0
Colorado 7 30
In my form if the state = Alabama then I need to Calulate a date field and
add the timeframe and additional days
Ex.
07/12/2004 (if state = Colorado, then add the timeframe (7) and the
additional days (30) to equal 03/14/2005

Can you tell me how to accomplish this?

  #4  
Old June 16th, 2005, 10:24 PM
dchristo
external usenet poster
 
Posts: n/a
Default

the State is in the Part A table and needs to equal the state in the DD
Timeframe table

ex. if [Part A]![State] = [dda timeframe].[state], then add the timeframe
and the
additional days


"George Nicholson" wrote:

NewDate = DateSerial(Year(OrigDate),
Month(OrigDate)+Dlookup("[Timeframe]","StateTable","[State] = '" &
StateValue & '"), Day(OrigDate) + DLookup("[AddlDays]","StateTable","[State]
= '" & StateValue & '"))

Whe
OrigDate is your "starting" Date
Table called StateTable contains the fields State, Timeframe and
AddlDays
StateValue is the name of the state you want to look up

If OrigDate = 7/12/2004 and StateValue = "Colorado" then
NewDate = DateSerial(Year(OrigDate), Month(OrigDate)+7, Day(OrigDate) +
30)
NewDate = 3/14/2005


HTH,
--
George Nicholson

Remove 'Junk' from return address.


"dchristo" wrote in message
...
I have a separate table that has the state code, the month, and day
ex.
state timeframe(months) addl days
Alabama 4 0
Colorado 7 30
In my form if the state = Alabama then I need to Calulate a date field and
add the timeframe and additional days
Ex.
07/12/2004 (if state = Colorado, then add the timeframe (7) and the
additional days (30) to equal 03/14/2005

Can you tell me how to accomplish this?




  #5  
Old June 16th, 2005, 10:56 PM
dchristo
external usenet poster
 
Posts: n/a
Default

But, how do I get the state , the state code in my form comes from Table
"Part A" and needs to equal the state in Table "DD Timeframe" and from there
get the timeframe and the addldays

ex. [Part A].[state] = [DD Timeframe].[state], then add the timeframe and
the
additional days

"Klatuu" wrote:

You just need the DateAdd function:
Add the Months:
CurrentDate = DateAdd("m",[timeframe],CurrentDate)
Add the Days:
CurrentDate = DateAdd("d",[addl days],CurrentDate)

"dchristo" wrote:

I have a separate table that has the state code, the month, and day
ex.
state timeframe(months) addl days
Alabama 4 0
Colorado 7 30
In my form if the state = Alabama then I need to Calulate a date field and
add the timeframe and additional days
Ex.
07/12/2004 (if state = Colorado, then add the timeframe (7) and the
additional days (30) to equal 03/14/2005

Can you tell me how to accomplish this?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple table lookup KG General Discussion 1 June 3rd, 2005 05:39 AM
Formula Question... LookUP G General Discussion 4 March 7th, 2005 01:38 AM
Lookup Functions Sharon Worksheet Functions 6 February 20th, 2005 05:04 AM
Help with LOOKUP (golf handicaps) Tom Ogilvy Worksheet Functions 19 December 15th, 2003 11:21 PM
Help with LOOKUP (golf handicaps) GoLions Worksheet Functions 0 December 14th, 2003 01:59 PM


All times are GMT +1. The time now is 03:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.