Results 1 to 2 of 2
  1. #1
    IanT is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2012
    Posts
    1

    Writing code on the fly - TransferSpreadsheet

    I want to set up a regular import of data from an excel spreadsheet using transferspreadsheet.

    Code:
    DoCmd.TransferSpreadsheet acImport, 8, "ImportTable", "F:\SalesDatabase\May2012.xlsx", True, "MonthlyImport"
    How can I use a variable to write this command on the fly, using the variable to determine which spreadsheet will be imported. The variable will hold the file name, which will be calculated from the currant month and year, eg VarCurrentImport = "May2012".

    Many thanks


    Ian

  2. #2
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262
    Try something like this:

    Code:
    dim mnthyr as string
    mnthyr=format(date, "mmmyyyy")
    
    DoCmd.TransferSpreadsheet acImport, 8, "ImportTable", "F:\SalesDatabase\" & mnthry & ".xlsx", True, "MonthlyImport"

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

Similar Threads

  1. Transferspreadsheet Method
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 11
    Last Post: 06-30-2011, 11:40 AM
  2. Transferspreadsheet Help Please
    By graviz in forum Programming
    Replies: 0
    Last Post: 11-30-2009, 02:56 PM
  3. Can't get TransferSpreadsheet to work
    By Valeda in forum Import/Export Data
    Replies: 0
    Last Post: 07-19-2007, 08:04 AM
  4. transferSpreadsheet
    By rabbit in forum Import/Export Data
    Replies: 1
    Last Post: 06-09-2006, 04:01 PM
  5. transferspreadsheet function
    By jeffj in forum Import/Export Data
    Replies: 3
    Last Post: 03-13-2006, 11:59 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