vba - Automating import of an Excel file -


i trying import file, saved in our public drive, access database table.

this have far.

dim timestamp2 string timestamp2 = month(date) & "." & day(date) - 1 & "." & year(date) dim xlfile string, shtname xlfile = "open orders @ " & timestamp2 & ".xls" shtname = "current open orders"  docmd.transferspreadsheet aclimport, acspreadsheettypeexcel12, "open orders yesterday", "\\cletus\knxgendb$\daily order bookings\open orders @ " & timestamp2 & ".xls", true, shtname & "!" 

this error i'm getting:

run time error 2306: there many rows output, based on limitation specified output format or microsoft access

here specific fixes:

  1. fix file extension. in 1 place have ".xlsx" , in another, ".xls"
  2. correct spelling of acimport (in code incorrectly spelled "aclimport")
  3. to delete table before import, try docmd.deleteobject actable, "open orders yesterday"
  4. when dimensioning multiple variables on same line, have provide variable type each or use default of variant. in case write dim xfile string, shtname string
  5. you don't use xfile variable. should either remove or add docmd.transferspreadsheet line avoid confusion.

and here together:

dim timestamp2 string timestamp2 = month(date) & "." & day(date) - 1 & "." & year(date) dim shtname string shtname = "current open orders"  'delete existing table docmd.deleteobject actable, "open orders yesterday"  'import data, recreating table docmd.transferspreadsheet aclimport, acspreadsheettypeexcel12, "open orders yesterday", "\\cletus\knxgendb$\daily order bookings\open orders @ " & timestamp2 & ".xls", true, shtname & "!" 

one question: sheet name "current open orders!"? if not, want remove exclamation mark end of docmd.transferspreadsheet aclimport, acspreadsheettypeexcel12, "open orders yesterday", "\\cletus\knxgendb$\daily order bookings\open orders @ " & timestamp2 & ".xls", true, shtname & "!"


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -