Results 1 to 7 of 7
  1. #1
    skydiver is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    4

    Coverting Excel sheet using vlookup tue wit Access DB

    I am new to Access so please bear with my lack of knowledge..

    I have an Access database I am setting up to replace an Excel workbook. The Access database is comprised of multiple tables but the one in question where I am stumped is as follows:
    Table: DSRData
    Item Amount Date FiscalPeriod
    Sales 10000.00 2/19/2014 ???
    Sales 850.00 1/14/2014 ???

    Table: FP
    PeriodStart PeriodEnd FP
    1/2/2014 1/29/2014 P01
    1/30/2014 2/26/2014 P02
    2/27/2014 4/2/2014 P03



    In Excel I could use a Vlookup *(true) to find the correct fiscal period to assign the data to from the FP table but i am at a bit of a loss as to how to do this in Access. I know I will need to do create a table join in access probably using a SQL query wit a conditional dsrdata.dob >= fy.periodstart AND dsrdata.dob <= fy.periodend but I haven't figured out how to dynamically assign the correct FP value to each row of data in the DSRData table.

    I have approximately 9 columns of data that will need this type of lookup. My goal is to create a replication of the Excel worksheet in Access that I can then save to our SharePoint site with Pivot charts of the full data set as a SharePoint Webpart.

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    try

    Code:
    SELECT *, Dlookup("FP","FPs",SaleDate & "Between PeriodStart AND PeriodEnd") AS FiscalPeriod
    FROM DSRData
    Or

    Code:
    SELECT *, (SELECT TOP 1 FP FROM FPs AS T WHERE DSRData.SaleDate Between PeriodStart AND PeriodEnd) AS FiscalPeriod
    FROM DSRData
    Note that Date is a reserved word, so change it to something else otherwise you will experience problems

    Also you have a table with a field the same name (FP) which will also cause problems. The normal convention is to use plurals for table names and the singular for field names - my code above reflects these changes

  3. #3
    skydiver is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    4
    SO do I save this as a Query then create a new column in the DSRData table that refers to the Query?

  4. #4
    skydiver is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    4
    Also is the Between statement inclusive?

    P01 start = 1/2/2014
    P01 end = 1/29/2014

    Does:
    lookup date 1/2/2014 = P01?
    lookup date 1/3/2014 = P01?
    lookup date 1/29/2014 = P01?

  5. #5
    skydiver is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    4
    I used the second query and it appears that this query looks up the entire DSRData table and adds the lookup column as part of the select query. As I said in the original post, I have 9 other tables where I am doing a similar lookup that need to be additional columns in the DSRData table Like Fiscal Week, Fiscal Year, PayPeriod, Etc.

    So I don't think that this is what I am looking for.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Cannot do DLookup (or any domain aggregate function) calcs in table. Can use IIf()

    Can also do calc for the fiscal period in a query then use that query in other queries.

    What are these 9 other tables? Want to post diagram of data structure?

    BETWEEN AND is inclusive.
    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.

  7. #7
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    SO do I save this as a Query then create a new column in the DSRData table that refers to the Query?
    save as a query, there is no need to add a new column into the DSRDate table, the query pulls the information through from that table. Access is a database, not a glorified Excel and treats data in a completely different way - suggest you research the principles of 'normalisation'

    As I said in the original post, I have 9 other tables where I am doing a similar lookup
    So create similar queries - again, suggest you research the principles of 'normalisation'

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

Similar Threads

  1. Replies: 1
    Last Post: 02-21-2014, 04:23 AM
  2. How to I update access with an excel sheet?
    By superfly5203 in forum Access
    Replies: 5
    Last Post: 01-24-2013, 10:52 AM
  3. Replies: 26
    Last Post: 01-08-2013, 04:55 PM
  4. Access and the concept VLOOKUP in Excel
    By Bob Blooms in forum Access
    Replies: 1
    Last Post: 08-27-2012, 12:28 PM
  5. Excel VLookup vs Access IIF statement
    By Huddle in forum Queries
    Replies: 9
    Last Post: 02-02-2012, 11:00 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