Results 1 to 2 of 2
  1. #1
    jogunjobi is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    2

    Vlookup in Access with SQL

    I'm trying to do a vlookup in access using sql and I need some help for an issue that's been giving me headaches and I'll try to explain as best as I can without confusing you.

    Table A contains the fields that I'm trying to use for the vlookups. The fields are as follows


    Table B is the table that I want to update based on the fields from Table A

    My current to update the DEPTID in table B is



    Code:
    UPDATE 
    Table B 
    INNER JOIN 
    Table A 
    ON [Table B].COST_CENTER = [Table A].Src_Cost_Ctr
    and [Table B].Combo_Map = [Table A].Cmb_ID
    and [Table B].LID = [Table A].Src_Com
    and [Table B].ACCOUNT = [Table A].Src_Acc
    SET 
    [Table B].DEPTID = [Table A]![DEPTID];
    That works fine for most of the sql queries. However, there will be some times when the "Src_Acc" does not exist in that column. In that instance, I want it the query to return the last DEPTID with the blank "Src_Acc" when it cannot find the account in that column.

    Thanks for your help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Is this duplication of data - why?

    Will probably need a subquery because need to pull value from another record. Not easy to do. Review this http://allenbrowne.com/subquery-01.html#AnotherRecord
    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.

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

Similar Threads

  1. working as a vlookup function
    By cleon in forum Queries
    Replies: 3
    Last Post: 12-16-2011, 02:51 PM
  2. Replies: 2
    Last Post: 12-08-2011, 12:03 AM
  3. Vlookup Question?
    By jjm3066 in forum Access
    Replies: 3
    Last Post: 11-15-2011, 11:55 AM
  4. Vlookup function in access
    By rici7 in forum Forms
    Replies: 1
    Last Post: 10-16-2010, 04:41 PM
  5. Access equiv to the vLookup in a Query
    By Scorpio11 in forum Queries
    Replies: 10
    Last Post: 07-07-2010, 11:36 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