I'm attempting to copy data from an excel sheet to a table in an access db. I came across some nice simple code, put in my own parameters, and just the ONCE it worked!
Now, despite everything appearing to be "as it was" it hangs with the db table open but nothing pasted into it and when debugging the vba in Excel it reports error 2501 runtime command cancelled.
Any ideas anyone?
code below:
Now, despite everything appearing to be "as it was" it hangs with the db table open but nothing pasted into it and when debugging the vba in Excel it reports error 2501 runtime command cancelled.
Any ideas anyone?
code below:
Code:
Sub Button1_Click()
Sheets("June 12th").Select
Range("a3:p58").Select
Selection.Copy
strDBName = "Data Export Trial.accdb"
strMyPath = "c:\Users\Lol\Desktop"
strDB = strMyPath & "\" & strDBName
Set appAccess = CreateObject("Access.Application")
' Open database in Microsoft Access window.
appAccess.OpenCurrentDatabase strDB
appAccess.Visible = True
appAccess.DoCmd.OpenTable "Tbl_Trial", acViewNormal, acEdit
appAccess.DoCmd.RunCommand acCmdPasteAppend
appAccess.CloseCurrentDatabase
appAccess.Quit acQuitSaveAll
End Sub