Results 1 to 6 of 6
  1. #1
    TheLost is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2012
    Location
    Boston
    Posts
    3

    Wink importing .csv and .xls files to access

    I'm importing .csv and .xls files into access using docmd.transferspreadsheet and it's simple enough except for a couple of issues I'm having:
    1. the .csv file has leading ' and if I converti it .txt if has leading " in some of the columns .....what's the best way to get rid of these and is it better before or after the importing process.



    2. a .xls file has a few rows of totals at the top so I need the importing to start at row A7 instead of A1...is there a way to control where it starts rather than manipulating the file prior to importing because it's all going to done by clicking a button on a form by user.

    oh, and there's a 3. one of the .xls has additional blank rows that it seems to import into the access table....what's th solution for that.

    All the files will vary in number of records on a daily basis so I can't specify range like the DoCmd.

    Any help would be greatly appreciated!
    Isabel.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,973
    1. the import transferspreadsheet method can't eliminate characters so must 'clean up' before or after.

    2. you can specify a range with transferspreadsheet method
    http://msdn.microsoft.com/en-us/library/bb214134(v=office.12).aspx

    3. must be something, even a space, in some cell on the row causing the row to import
    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.

  3. #3
    TheLost is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2012
    Location
    Boston
    Posts
    3
    Do you know how to update the table column with an expression that would that would update the column with a replace ....to replace the "'" with ""?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,973
    Try:

    UPDATE Table1 SET Table1.test = Replace([test],"'","");

    I just noticed your statement about the variability of rows.

    VBA code could read the file and determine the last row with data and use that to define the range.
    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.

  5. #5
    TheLost is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2012
    Location
    Boston
    Posts
    3
    ok, I think if I put that Update code in a query it might fix the problem.
    I had already seen that info in the link you provided....seems like there should be an easier way to determine the end of the data.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,973
    I don't see anything in that link that would programmatically determine the last row holding data. It does describe the syntax for the Range parameter but it does not determine what the last row of data is.
    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. Importing Text files
    By RayMilhon in forum Programming
    Replies: 4
    Last Post: 10-10-2011, 10:54 PM
  2. Importing files into Access 2007
    By rjani1 in forum Access
    Replies: 6
    Last Post: 07-19-2011, 09:33 AM
  3. importing Dbase files
    By dzawicki in forum Import/Export Data
    Replies: 2
    Last Post: 01-14-2010, 05:43 PM
  4. Importing multiple files at once
    By NoiCe in forum Import/Export Data
    Replies: 1
    Last Post: 04-01-2009, 10:10 AM
  5. Importing Xls and CSV files into MS Access
    By Jeff in forum Import/Export Data
    Replies: 1
    Last Post: 02-17-2009, 11:56 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