G
Guest
Hello all.
I have two tables with the following fields:
Table1: Rate_Table
Field1: Resource ID
Field2: Rate
Field3: Date_Start
Field4: Date_End
Table2: Data_DUMP
Field1: Resource ID
Field2: Start Date
Field3: End Date
Field4: Hours
I'm building a query that I need to pull all fields from Data_DUMP and only
the rate from Rate_Table. However, in Rate_Table, I will have a Resource ID
listed more than once with different start/end dates and different rates.
Essentially, a Resource may have their rates change from one year to another.
For example, this would be the data in Rate_table:
Resource ID Date_Start Date_End Rate
JSmith 01/01/2006 12/31/2006 20
JSmith 01/01/2007 12/31/2007 30
Here is an example of the Data_DUMP:
Resrouce ID Start Date End Date Hours
JSmith 02/14/06 02/21/06 10
JSmith 02/22/06 02/28/06 8
....
JSmith 04/07/07 04/14/07 9
LJones 04/07/07 04/14/07 10
When I build my query, I need to make sure I pull the correct rate, based on
the start and end dates of the Data_DUMP table. So, in order for me to pull
the correct rate, three comparisons need to happen:
1. Data_Dump.Resource ID = Rate_Table.Resource ID
2. Data_Dump.[Start Date] >= Rate_table.Date_Start
3. Data_Dump.[End Date] <= Rate_Table.Date_End
When the two tables are compared, the correct rate should be pulled into the
query based on the above criteria. It should look like the following:
Resrouce ID Start Date End Date Hours Rate
JSmith 02/14/06 02/21/06 10 20
JSmith 02/22/06 02/28/06 8 20
JSmith 04/07/07 04/14/07 9 30
LJones 04/07/07 04/14/07 10 <null>
I included the LJones example to show that I need to know if a record
doesn't have a rate included. If it comes back as blank or null, then I know
I need to update the Rate_Table.
Cacn someone help me build the correct lookup expression? Is a lookup
expression not the correct approach? I've tried dLookUp() but I can't seem
to get it to pull the correct rate correctly. I hope my example is clear and
I due appreciate all your help.
Thanks in advance!
The Dude
I have two tables with the following fields:
Table1: Rate_Table
Field1: Resource ID
Field2: Rate
Field3: Date_Start
Field4: Date_End
Table2: Data_DUMP
Field1: Resource ID
Field2: Start Date
Field3: End Date
Field4: Hours
I'm building a query that I need to pull all fields from Data_DUMP and only
the rate from Rate_Table. However, in Rate_Table, I will have a Resource ID
listed more than once with different start/end dates and different rates.
Essentially, a Resource may have their rates change from one year to another.
For example, this would be the data in Rate_table:
Resource ID Date_Start Date_End Rate
JSmith 01/01/2006 12/31/2006 20
JSmith 01/01/2007 12/31/2007 30
Here is an example of the Data_DUMP:
Resrouce ID Start Date End Date Hours
JSmith 02/14/06 02/21/06 10
JSmith 02/22/06 02/28/06 8
....
JSmith 04/07/07 04/14/07 9
LJones 04/07/07 04/14/07 10
When I build my query, I need to make sure I pull the correct rate, based on
the start and end dates of the Data_DUMP table. So, in order for me to pull
the correct rate, three comparisons need to happen:
1. Data_Dump.Resource ID = Rate_Table.Resource ID
2. Data_Dump.[Start Date] >= Rate_table.Date_Start
3. Data_Dump.[End Date] <= Rate_Table.Date_End
When the two tables are compared, the correct rate should be pulled into the
query based on the above criteria. It should look like the following:
Resrouce ID Start Date End Date Hours Rate
JSmith 02/14/06 02/21/06 10 20
JSmith 02/22/06 02/28/06 8 20
JSmith 04/07/07 04/14/07 9 30
LJones 04/07/07 04/14/07 10 <null>
I included the LJones example to show that I need to know if a record
doesn't have a rate included. If it comes back as blank or null, then I know
I need to update the Rate_Table.
Cacn someone help me build the correct lookup expression? Is a lookup
expression not the correct approach? I've tried dLookUp() but I can't seem
to get it to pull the correct rate correctly. I hope my example is clear and
I due appreciate all your help.
Thanks in advance!
The Dude