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:
- fix file extension. in 1 place have ".xlsx" , in another, ".xls"
- correct spelling of
acimport
(in code incorrectly spelled "aclimport") - to delete table before import, try
docmd.deleteobject actable, "open orders yesterday"
- 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
- you don't use
xfile
variable. should either remove or adddocmd.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
Post a Comment