Results 1 to 5 of 5
  1. #1
    pickslides is offline Novice
    Windows 10 Access 2013
    Join Date
    Dec 2015
    Location
    Melbourne, Australia
    Posts
    9

    Writing a Query to match Excel lookups

    Hi there, I have attached an XLS file I wish to replicate in Access using


    querie(s).

    I seem to be losing too many records with my attempts.


    The XLS sheet has 281 records when appending data using lookups and the
    Access Query only has 213 records.


    TIMESHEET has 281 records but I want to append the following fields to
    this table

    Append
    Code:
    catchment.display_text
    Using the relationship
    Code:
    Catchment.entity_id = 
    CASES.assignee_user_id
    AND

    Append
    Code:
    Subtype.display_text
    Using the relationship
    Code:
    Subtype.entity_id = 
    CASES.id
    AND

    ALSO needing to join
    Code:
     
    
     Timesheet.description2 = CASES.reference_number

    Thx, MQ
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    in access, just a simple query is the same as a lookup.
    put what you want to find in the criteria and run.

  3. #3
    pickslides is offline Novice
    Windows 10 Access 2013
    Join Date
    Dec 2015
    Location
    Melbourne, Australia
    Posts
    9
    Hi, thanks for the reply.

    I do know that is the idea but for some reason as I make the joins I lose records.

    In XLS I can lookup the values and #NA will appear if required, in Access the record is lost. I know how to use the left and right joins but when I link more then one table I lose some records.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Table relationship links should use Primary Key and Foreign Key fields. Your designated Primary Key fields are not utilized in the links.

    Your table relationships as established in the query don't make sense. What is the nature of this data? Which table is 'parent', which tables are 'dependent', which tables are 'lookups'?

    However, shouldn't catchment entity_id be linking to CASES assignee_group_id? This is what the Excel VLookup is doing.

    Forget everything you know about Excel when building relational database. Here is a good tutorial site http://www.rogersaccesslibrary.com/


    Here is the Access equivalent for AssigneeGroupID and Catchment VLookup:
    SELECT Timesheet.*, DLookUp("assignee_group_id", "Cases", "reference_number='" & [description2] & "'") AS AssigneeGroupID, DLookUp("display_text","catchment","entity_id='" & [AssigneeGroupID] & "'") AS Catchment FROM Timesheet;


    Why do you have Choose() in the VLookup for CaseID? Why is the table array only one column, shouldn't there be at least 2?


    Consider this query:

    SELECT Timesheet.*, CASES.id, CASES.assignee_group_id, catchment.display_text, catchment.field_name, Subtype.display_text, Subtype.field_name
    FROM Subtype RIGHT JOIN (catchment RIGHT JOIN (CASES RIGHT JOIN Timesheet ON CASES.reference_number = Timesheet.description2) ON catchment.entity_id = CASES.assignee_group_id) ON Subtype.entity_id = catchment.entity_id;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Its possible the data in both table does not match exactly,

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

Similar Threads

  1. Replicating and Excel INDEX - MATCH with DLOOKUP
    By Richey1977 in forum Queries
    Replies: 5
    Last Post: 05-21-2015, 08:27 AM
  2. Use Excel like Choose & Match
    By crimedog in forum Reports
    Replies: 2
    Last Post: 04-10-2015, 12:47 PM
  3. Writing a sum from a query into a new table
    By roar58 in forum Queries
    Replies: 15
    Last Post: 10-27-2014, 04:56 PM
  4. Writing a Query!
    By dsaxena15 in forum Queries
    Replies: 1
    Last Post: 11-15-2012, 03:35 PM
  5. Replies: 1
    Last Post: 09-30-2012, 07:03 AM

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