Results 1 to 2 of 2
  1. #1
    TheRealMcGee is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    5

    File importing: directing rows in Excel sheet based on condition

    I'm wondering if this is possible and, if so, a web resource that can show me how to do it. Essentially I have multiple Excel spreadsheets maintained and updated by outside parties that need to be periodically imported into my database. Problem is I can't just use the simple import function in Access as the data in the spreadsheets need to go in one of three tables based on the data in the "Type" row of the spreadsheet. A simplified version the spreadsheet looks like this:

    ID | Type | Content
    1 | Type A | Content for ID 1
    2 | Type C | Content for ID 2
    3 | Type B | Content for ID 3


    4 | Type A | Content for ID 4
    5 | Type B | Content for ID 5
    6 | Type C | Content for ID 6
    7 | Type B | Content for ID 7

    My database has three tables: Type A, Type B, Type C. When importing the spreadsheets, the rows in the spreadsheet needs to be siphoned into the appropriate table on the basis of Type. In the above spreadsheet, IDs 1 and 4 need to update the "Type A" table, IDs 3, 5 and 7 the "Type B" table, and IDs 2 and 6 the "Type C" table. Also, most of the time it will an updating of exiting rows in the tables, but sometimes new rows will need to be inserted, thus new IDs generated.

    Many thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Save the XL book to the same place...c:\temp\file2import.xlsx
    link it into the db as an external table.
    make all your import queries to import the data into the target tables.
    put all these queries into a macro.
    Put a macro in XL to run the SAVE AS c:\temp\file2import.xlsx

    then the steps are:
    get the new file, run the xl SaveAs macro,
    then run the access imort macro,
    done.

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

Similar Threads

  1. Replies: 5
    Last Post: 04-25-2017, 01:38 AM
  2. Importing Excel File - Getting 7 extra blank rows each import
    By eking002 in forum Import/Export Data
    Replies: 4
    Last Post: 06-13-2013, 09:15 AM
  3. Importing Excel file based on Criteria
    By Kinez101 in forum Programming
    Replies: 1
    Last Post: 04-18-2012, 12:55 PM
  4. Importing full excel sheet to access
    By karakal in forum Import/Export Data
    Replies: 0
    Last Post: 03-22-2010, 03:48 PM
  5. Importing Excel Sheet into Access dbase
    By tonystowe in forum Import/Export Data
    Replies: 0
    Last Post: 12-08-2006, 11:35 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