Link to home
Start Free TrialLog in
Avatar of kbdaemon
kbdaemonFlag for United States of America

asked on

Challenging Access question: conditional date range query between two tables

I have two tables in Access 2010 (database4 is attached) with test data.  One table contains agents by code and the amount of commission they earn for selling product "WLLB".  The other table contains commission levels by date.  Commission contracts change over time and we are reconstructing some really old data for export to a newer system (for records purposes).

I need to create a query to return records where:
1) [AgentTestRecords].AgtComm = [CommLevelsByDate].CommPctYr1 AND
2) [AgentTestRecords].PolType = [CommLevelsByDate].ProductCode AND
3) [CommLevelsByDate].ANBTo = 70 AND
4) [AgentTestRecords].ContractDate => [CommLevelsByDate].ValidFrom and <=[CommLevelsByDate].ValidTo

The result set would be: [AgentTestRecords].Agt as AgentCode, [CommLevelsByDate].ProducerTier as ProducerTier, [CommLevelsByDate].ValidFrom as CommScheduleDate and [AgentTestRecords].ContractDate as ContractDate

So, I know what I want but I am in over my head on doing something that looks like a union with a bunch of conditionals versus my simple select query experience.  Thanks in advance for any help!

Kirk
Database4.accdb
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kbdaemon

ASKER

Will do in about an hour just left office
Thanks! that gets me exactly what I need.