Results 1 to 7 of 7
  1. #1
    nica12 is offline Novice
    Windows 11 Access 2021
    Join Date
    Oct 2023
    Posts
    4

    Importing certain columns from a flat database into Access

    Hi,

    I am creating a database in Access which will use data imported from flat Excel database - this excel database is very wide with 255+ columns. The source Excel database will be often updated as raw data is run through Power Query for cleaning and the source database will be the PowerQuery output. In importing the Excel data into Access, I ideally want to only import certain columns into each of my individual normalized tables in Access. I would like to do this through linked tables so that the database in Access can be easily updated as the Excel spreadsheet (where the data is pulled from is updated).

    The questions I therefore have is: 1) What is the best/simplest way to import just certain columns? Is this possible? Or do I have to split my Excel database into normalised tables first?

    2) Once I have imported data through linking - I understand that the tables cannot be amended in Access. Can I still merge or append tables together through primary/foreign keys? Or will I have to import files to be able to do this?



    Thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    attach the text file as an external table,
    then make an append query to import the columns and data you wish.


    text files require a SPEC file to define the columns so there's some pre-steps to take:

    ---------------
    PREP
    ---------------
    1st, manually import the text file,
    in the 'import screen' ,bottom left corner is ADVANCED
    define your fields in the text as an IMPORT SPEC.
    SAVE this spec. (i.e: "SpecName")

    manually link this CSV file using the spec name so it becomes an External Table: txtFile2Import

    make an append query to append the txtFile2Import fields to the target table: qaImportCsvFile

    ---------------
    EXECUTION
    ---------------
    1. each new CSV file you get, save it to the same place every time,like: c:\temp\txtFile2Import.csv
    2. run the import query: docmd.openquery "qaImportCsvFile"
    3. Done

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Linking to a file with 255+ columns won't work, at least not all columns can be pulled by the link. How many of these columns do you want? You are transposing the data in Access to normalized structure? If not, what do you meany by 'normalized'?

    It is possible to build a query that links to Excel, CSV or TXT file and specify columns to retrieve. I am just not sure if this can reference columns beyond the 255 limit. Example:

    SELECT Seq, Unit, Garage FROM [Units$] IN 'C:\Users\Owner\June\MyStuff\Condos.xlsx'[Excel 12.0;HDR=yes;IMEX=1;ACCDB=Yes];

    Modify IMEX=0 and can even edit linked worksheet, although not delete rows.

    Could attach sample Excel file for analysis. Follow instructions at bottom of my post.

    Is this your cross-post https://www.access-programmers.co.uk...-limit.329246/
    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.

  4. #4
    nica12 is offline Novice
    Windows 11 Access 2021
    Join Date
    Oct 2023
    Posts
    4
    Thank you very much for your helpful reply, and sorry I was unclear, I am very new to Access and it's all quite a steep learning curve! That is correct, I am wanting to transpose the data to a normalized structure. For example, I have a referral information table, and I would like to only import certain relevant columns (say, "Referral ID", "Referral date", and "Referral reason") from my large Excel spreadsheet (stored on SharePoint).

    Is it possible to build a query which links to the SharePoint site, and specifies columns to retrieve?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I have never used SharePoint but apparently the External Data wizard can establish link. However, still have 255 field limit.

    No idea if the query method I posted could work.

    What you describe is not transposing data, it is just pulling particular fields. Transposing would be converting fields to rows (unpivot) - as described in other forum thread - or rows to fields (pivot).
    Last edited by June7; 11-09-2023 at 04:30 PM.
    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.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    It is possible to build a query that links to Excel, CSV or TXT file and specify columns to retrieve. I am just not sure if this can reference columns beyond the 255 limit
    no it’s not possible. Even if you set a range table, it won’t be recognised if it extends beyond the 255th column
    Last edited by CJ_London; 11-09-2023 at 07:07 PM.

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I think you would have to use Automation, as long as you always knew (or could derive) the table fields you need out of the 255+ fields.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 15
    Last Post: 01-05-2021, 07:30 PM
  2. Replies: 1
    Last Post: 03-26-2016, 06:42 AM
  3. Replies: 9
    Last Post: 12-09-2015, 01:45 PM
  4. Replies: 7
    Last Post: 11-07-2014, 10:01 AM
  5. Normalize a flat database
    By worldwidewall in forum Access
    Replies: 5
    Last Post: 03-23-2012, 04:06 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