Imports

G

Guest

I am creating a macro to transfer information from Excel
to Access. Every other time I run it I get an error
stating that "You cannot carry out the action at the
present time". I have a feeling that Access is not closing
properly after I run it the first time. Why am I getting
this error? How do I fix this? Also -- how can I get the
Access window to close -- the database closes just not the
window? Below is my code. Thank You

Dim dba As Access.Application
Dim stgPath As String
Set dba = CreateObject("access.application")
stgPath = ("C:\fink\sta.mdb")
dba.OpenCurrentDatabase filepath:=stgPath
DoCmd.SetWarnings False
DoCmd.OpenQuery "Delete UnlCdL", , acEdit
DoCmd.TransferSpreadsheet acImport, , _
"CD LSTN", ThisWorkbook.FullName, True, "Pcday"
DoCmd.SetWarnings True
dba.CloseCurrentDatabase
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top