Results 1 to 4 of 4
  1. #1
    JackA is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    10

    Query problem - probably simple but I am a novice!

    I am an access novice and need some help pretty badly. My problem is as follows:

    I have two tables of data like below

    Table1
    TopCode SubCode Item
    ABC ABC FishA
    ABC ABCD FishB
    ADF ADFG PhoneA


    ADF ADFH PhoneB

    Table 2
    SubCode Date
    ABC 01/01/2001
    ABCD 01/01/2001
    ADFG 05/02/2003
    ADFH 04/02/2003

    I want to run a query that produces the following

    TopCode Date
    ABC 01/01/2001
    ADF 04/02/2003

    Where the date is added by matching the SubCode from Table 2, with the TopCode from Table 1. If there is no TopCode match, I would like the match to be made by matching the SubCode from Table 2, with the SubCode from Table 1 with the oldest date chosen (e.g. 04/02/2003 rather than 05/02/2003).

    At the moment all I have is

    TopCode Date
    ABC 01/01/2001

    And ADF is removed from the result.

    Can any Access wizards help with this problem?

    I would really appreciate a reply

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Where the date is added by matching the SubCode from Table 2, with the TopCode from Table 1. If there is no TopCode match, I would like the match to be made by matching the SubCode from Table 2, with the SubCode from Table 1 with the oldest date chosen (e.g. 04/02/2003 rather than 05/02/2003).
    Once you make a join (top code of table1 to subcode of table2) you cannot alter that join during the execution of the query.

    From what I see, your tables are not structure properly.

    What are top and sub codes and how do they relate to one another?

    Can you please provide more info on the business process you are modeling?

  3. #3
    JackA is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    10
    I am restricted by the tables structure and can not change them.

    The only other thing I can add is that there is also a TopName and SubName.

    I am basically creating an access database for reporting on the performance of funds in terms of size of assets and amount of sales (with attention paid to when they were created). Where I extract data from 3 sources, Assets, Sales and CreationDate. Link them together, then get Assets + Sales + CreationDate report, which varies on Dates of Sales and Asset counts.

    Hope that helps.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Do the items in your TABLE2 have a 1 to 1 relationship with the SUBCODE in your TABLE1?

    In other words could you have something like:

    Code:
    Table1
    TopCode SubCode Item
    ABC     ABC     BLAHBLAH
    ADF     ABC     BLAHBLAH
    if so how are you linking the two tables?

    Is it possible in TABLE2 to have:

    Code:
    Table2
    SubCode SubCodeDate
    ABC     1/1/2001
    ABC     1/15/2001
    ABC     1/1/2011
    You seem to say in your original post that you want to pick out the most recent record if so then I have to assume your TABLE2 can have multiple records for each subcode?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Simple export for the Access novice
    By VictoriaAlbert in forum Import/Export Data
    Replies: 4
    Last Post: 06-15-2011, 01:33 AM
  2. Novice at best
    By jmorse in forum Reports
    Replies: 8
    Last Post: 04-19-2011, 03:21 PM
  3. Simple Problem with Validations
    By oleBucky in forum Forms
    Replies: 11
    Last Post: 04-12-2011, 05:39 PM
  4. Simple query problem
    By rajnag in forum Access
    Replies: 4
    Last Post: 08-19-2010, 05:09 AM
  5. simple form problem
    By kcsun in forum Forms
    Replies: 0
    Last Post: 08-12-2010, 12:28 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums