Results 1 to 5 of 5
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    DoCmd.TransferSpreadsheet acImport


    How does one load a table from an Excel spreadsheet WITHOUT sucking in hundreds of blank records. (I don't own the Excel file, so I get whatever I get) I can get around the problem with a subsequent query that excludes the blank records or quit processing when code encounters the first "essential field", but it would be nice to know if import function provides for it.

    Code:
    DoCmd.TransferSpreadsheet acImport, , "tblEXCEL-PRKG", strExcelName, True

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Attach The workbook as an external table,
    then make an append query to exclude the blanks.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks, I knew there had to be a way.

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    I figured you already had linked the sheet as a table
    I can get around the problem with a subsequent query
    AFAIK, you cannot link a workbook - only a worksheet?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    The table is created anew with the TransferSpreadSheet. I then select it then as a DAO Recordset to process the records. The OP simply has to do with the way Excel extends its spreadsheets with a bunch of empty records, I was hoping there was an Access method with the DoCmd.TransferSpreadSheet that would provide for those records to be ignored.

    My solution is/was more along the lines that Ranman suggested, only without the append.
    Code:
    strSQL = "SELECT * FROM tblExcelPrkg WHERE (Apt Is Not Null);"
    Set rsExcel = DBEngine(0)(0).OpenRecordset(strSQL, dbOpenDynaset)

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

Similar Threads

  1. DoCmd.TransferSpreadsheet
    By mp3909 in forum Access
    Replies: 2
    Last Post: 03-21-2019, 06:38 AM
  2. Replies: 4
    Last Post: 06-27-2018, 01:11 PM
  3. Replies: 12
    Last Post: 05-31-2016, 02:12 PM
  4. Replies: 8
    Last Post: 07-02-2014, 10:58 AM
  5. DoCmd.TransferDatabase acImport Issue
    By remingtont in forum Programming
    Replies: 0
    Last Post: 11-12-2010, 03:59 PM

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