M
MM
Hi folks, I hope someone can help me....
I'm working on a macro to do the following from excel:
i) open an access database if it is not already open
ii) copy the contents of the active cell ("job number") in a worksheet into
an access form and then run a macro to view the related job details.
I am trying to use the Transfer Spreadsheet method but cannot get it to
work. I keep getting eror 3011.
Here's the code:
Sub RunAccessMacro()
Dim appAcc As Access.Application
'Open Access or use it if already running
Set appAcc = New Access.Application
'open desired database
With appAcc
.Visible = False
.OpenCurrentDatabase "C:\Documents and Settings\User\My
Documents\Works in progress\database stuff\Copy of job list.mdb"
.DoCmd.RunMacro "GenSearch" 'opens a search form
.DoCmd.TransferSpreadsheet acImport, , "Search",
"C:\data\control\stations.xls", , ActiveCell
^^^
This is where it goes wrong. Error 3011 says Jet Database Engine could not
find the object "011524A" (i.e. the contents of the ActiveCell)
.DoCmd.RunMacro "Search" 'macro to view job details
.Visible = True
End With
End Sub
Apologies for the scrappy code - it's been scavenged from all over the place
.
Yours hopefully,
Marcel
I'm working on a macro to do the following from excel:
i) open an access database if it is not already open
ii) copy the contents of the active cell ("job number") in a worksheet into
an access form and then run a macro to view the related job details.
I am trying to use the Transfer Spreadsheet method but cannot get it to
work. I keep getting eror 3011.
Here's the code:
Sub RunAccessMacro()
Dim appAcc As Access.Application
'Open Access or use it if already running
Set appAcc = New Access.Application
'open desired database
With appAcc
.Visible = False
.OpenCurrentDatabase "C:\Documents and Settings\User\My
Documents\Works in progress\database stuff\Copy of job list.mdb"
.DoCmd.RunMacro "GenSearch" 'opens a search form
.DoCmd.TransferSpreadsheet acImport, , "Search",
"C:\data\control\stations.xls", , ActiveCell
^^^
This is where it goes wrong. Error 3011 says Jet Database Engine could not
find the object "011524A" (i.e. the contents of the ActiveCell)
.DoCmd.RunMacro "Search" 'macro to view job details
.Visible = True
End With
End Sub
Apologies for the scrappy code - it's been scavenged from all over the place
.
Yours hopefully,
Marcel