ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Docmd.Transferdatabase error (https://www.excelbanter.com/excel-programming/426495-docmd-transferdatabase-error.html)

eggpap[_24_]

Docmd.Transferdatabase error
 

Hello,

In a workbook I need to import tables from one mdb password protected
database to another mdb unprotected database. I though to use the
following subroutine:

Sub Export(dbname As String, tbSource As String, tbDestination As
String)
Dim dbSourcePath As String, dbTargetPath As String, oApp As
Access.Application
On Error GoTo err_hnd
'Path dbname
Application.AutomationSecurity = msoAutomationSecurityLow
dbSourcePath = ThisWorkbook.Path & "\" & dbname
dbTargetPath = ThisWorkbook.Path & "\" & "ImportExport.mdb"
'Apre Access
Set oApp = CreateObject("Access.Application")
oApp.Visible = False
'Apre nomedb
oApp.OpenCurrentDatabase dbSourcePath, , PWORD
oApp.DoCmd.TransferDatabase acExport, "MS Access", dbTargetPath,
acTable, tbSource, tbDestination
oApp.Quit
Set oApp = Nothing
Exit Sub
err_hnd:
MsgBox Err.Description & "/" & Err.Number & " Sub Export"
Resume Next
End Sub

However I get the 2507 error on the docmd.transferdatabase statement
that says "MS Access database type not installed or task not allowed"

Any tip?
Thanks


--
eggpap

Excel 2003 on Vista HP System - can use VBA
------------------------------------------------------------------------
eggpap's Profile: http://www.thecodecage.com/forumz/member.php?userid=90
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=83143


joel

Docmd.Transferdatabase error
 
Your parameter don't seem correct. If you skip some paraters then you must
include the parameter name usin ":=". I also thing if you are need a file
name not a Path. I think you want to concatenate the path with the filename.


oApp.DoCmd.TransferDatabase _
TransferType:=acExport, _
DatabaseName:="MS Access", _
dbTargetPath, _
acTable, _
tbSource, _
tbDestination

expression.TransferDatabase( _
TransferType, _
DatabaseType, _
DatabaseName, _
ObjectType, _
Source, _
Destination, _
StructureOnly, _
StoreLogin)

"eggpap" wrote:


Hello,

In a workbook I need to import tables from one mdb password protected
database to another mdb unprotected database. I though to use the
following subroutine:

Sub Export(dbname As String, tbSource As String, tbDestination As
String)
Dim dbSourcePath As String, dbTargetPath As String, oApp As
Access.Application
On Error GoTo err_hnd
'Path dbname
Application.AutomationSecurity = msoAutomationSecurityLow
dbSourcePath = ThisWorkbook.Path & "\" & dbname
dbTargetPath = ThisWorkbook.Path & "\" & "ImportExport.mdb"
'Apre Access
Set oApp = CreateObject("Access.Application")
oApp.Visible = False
'Apre nomedb
oApp.OpenCurrentDatabase dbSourcePath, , PWORD
oApp.DoCmd.TransferDatabase acExport, "MS Access", dbTargetPath,
acTable, tbSource, tbDestination
oApp.Quit
Set oApp = Nothing
Exit Sub
err_hnd:
MsgBox Err.Description & "/" & Err.Number & " Sub Export"
Resume Next
End Sub

However I get the 2507 error on the docmd.transferdatabase statement
that says "MS Access database type not installed or task not allowed"

Any tip?
Thanks


--
eggpap

Excel 2003 on Vista HP System - can use VBA
------------------------------------------------------------------------
eggpap's Profile: http://www.thecodecage.com/forumz/member.php?userid=90
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=83143



Dave Patrick

Docmd.Transferdatabase error
 
You can't use named arguments in this manner. You didn't provide a value for
TransferType. Try substituting a 1 for the argument 'acExport'


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"eggpap" wrote:

Hello,

In a workbook I need to import tables from one mdb password protected
database to another mdb unprotected database. I though to use the
following subroutine:

Sub Export(dbname As String, tbSource As String, tbDestination As
String)
Dim dbSourcePath As String, dbTargetPath As String, oApp As
Access.Application
On Error GoTo err_hnd
'Path dbname
Application.AutomationSecurity = msoAutomationSecurityLow
dbSourcePath = ThisWorkbook.Path & "\" & dbname
dbTargetPath = ThisWorkbook.Path & "\" & "ImportExport.mdb"
'Apre Access
Set oApp = CreateObject("Access.Application")
oApp.Visible = False
'Apre nomedb
oApp.OpenCurrentDatabase dbSourcePath, , PWORD
oApp.DoCmd.TransferDatabase acExport, "MS Access", dbTargetPath,
acTable, tbSource, tbDestination
oApp.Quit
Set oApp = Nothing
Exit Sub
err_hnd:
MsgBox Err.Description & "/" & Err.Number & " Sub Export"
Resume Next
End Sub

However I get the 2507 error on the docmd.transferdatabase statement
that says "MS Access database type not installed or task not allowed"

Any tip?
Thanks


--
eggpap

Excel 2003 on Vista HP System - can use VBA
------------------------------------------------------------------------
eggpap's Profile: http://www.thecodecage.com/forumz/member.php?userid=90
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=83143



joel

Docmd.Transferdatabase error
 
Dave: You are wrong. If you have the Access Referernce library selected
excel will recognize this parameter. OPenCurrent Database is not producing
an error so the arguments are being recognized.

"Dave Patrick" wrote:

You can't use named arguments in this manner. You didn't provide a value for
TransferType. Try substituting a 1 for the argument 'acExport'


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"eggpap" wrote:

Hello,

In a workbook I need to import tables from one mdb password protected
database to another mdb unprotected database. I though to use the
following subroutine:

Sub Export(dbname As String, tbSource As String, tbDestination As
String)
Dim dbSourcePath As String, dbTargetPath As String, oApp As
Access.Application
On Error GoTo err_hnd
'Path dbname
Application.AutomationSecurity = msoAutomationSecurityLow
dbSourcePath = ThisWorkbook.Path & "\" & dbname
dbTargetPath = ThisWorkbook.Path & "\" & "ImportExport.mdb"
'Apre Access
Set oApp = CreateObject("Access.Application")
oApp.Visible = False
'Apre nomedb
oApp.OpenCurrentDatabase dbSourcePath, , PWORD
oApp.DoCmd.TransferDatabase acExport, "MS Access", dbTargetPath,
acTable, tbSource, tbDestination
oApp.Quit
Set oApp = Nothing
Exit Sub
err_hnd:
MsgBox Err.Description & "/" & Err.Number & " Sub Export"
Resume Next
End Sub

However I get the 2507 error on the docmd.transferdatabase statement
that says "MS Access database type not installed or task not allowed"

Any tip?
Thanks


--
eggpap

Excel 2003 on Vista HP System - can use VBA
------------------------------------------------------------------------
eggpap's Profile: http://www.thecodecage.com/forumz/member.php?userid=90
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=83143




Dave Patrick

Docmd.Transferdatabase error
 
The OP is using late binding so I assumed there was no reference.



--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"joel" wrote:
Dave: You are wrong. If you have the Access Referernce library selected
excel will recognize this parameter. OPenCurrent Database is not
producing
an error so the arguments are being recognized.



Dave Peterson

Docmd.Transferdatabase error
 
I don't think so.

This is the line that's important:
Dim oApp As Access.Application
(removed the first few variables)

means early binding.

I wouldn't use this line with that declaration, but it's not important.
Set oApp = CreateObject("Access.Application")

Dave Patrick wrote:

The OP is using late binding so I assumed there was no reference.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"joel" wrote:
Dave: You are wrong. If you have the Access Referernce library selected
excel will recognize this parameter. OPenCurrent Database is not
producing
an error so the arguments are being recognized.


--

Dave Peterson

Dave Patrick

Docmd.Transferdatabase error
 
Yes, I missed that but isn't the last assignment for oApp what's important?


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"Dave Peterson" wrote:
I don't think so.

This is the line that's important:
Dim oApp As Access.Application
(removed the first few variables)

means early binding.

I wouldn't use this line with that declaration, but it's not important.
Set oApp = CreateObject("Access.Application")


eggpap[_25_]

Docmd.Transferdatabase error
 

joel;297512 Wrote:
Your parameter don't seem correct. If you skip some paraters then you
must
include the parameter name usin ":=". I also thing if you are need a
file
name not a Path. I think you want to concatenate the path with the
filename.

oApp.DoCmd.TransferDatabase _
TransferType:=acExport, _
DatabaseName:="MS Access", _
dbTargetPath, _
acTable, _
tbSource, _
tbDestination

expression.TransferDatabase( _
TransferType, _
DatabaseType, _
DatabaseName, _
ObjectType, _
Source, _
Destination, _
StructureOnly, _
StoreLogin)


Thanks to all,

I tried this

oApp.DoCmd.TransferDatabase TransferType:=acExport, DatabaseType:="MS
Access", DatabaseName:=dbTargetPath, ObjectType:=acTable,
Source:=tbSource, Destination:=tbDestination

but I get the same error.

Here attached the test wb to replicate the error


+-------------------------------------------------------------------+
|Filename: proveexport.xls |
|Download: http://www.thecodecage.com/forumz/attachment.php?attachmentid=104|
+-------------------------------------------------------------------+

--
eggpap

Excel 2003 on Vista HP System - can use VBA
------------------------------------------------------------------------
eggpap's Profile: http://www.thecodecage.com/forumz/member.php?userid=90
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=83143


Dave Patrick

Docmd.Transferdatabase error
 
Also note the DatabaseType should be "Microsoft Access" not "MS Access"


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"eggpap" wrote:

joel;297512 Wrote:
Your parameter don't seem correct. If you skip some paraters then you
must
include the parameter name usin ":=". I also thing if you are need a
file
name not a Path. I think you want to concatenate the path with the
filename.

oApp.DoCmd.TransferDatabase _
TransferType:=acExport, _
DatabaseName:="MS Access", _
dbTargetPath, _
acTable, _
tbSource, _
tbDestination

expression.TransferDatabase( _
TransferType, _
DatabaseType, _
DatabaseName, _
ObjectType, _
Source, _
Destination, _
StructureOnly, _
StoreLogin)


Thanks to all,

I tried this

oApp.DoCmd.TransferDatabase TransferType:=acExport, DatabaseType:="MS
Access", DatabaseName:=dbTargetPath, ObjectType:=acTable,
Source:=tbSource, Destination:=tbDestination

but I get the same error.

Here attached the test wb to replicate the error


+-------------------------------------------------------------------+
|Filename: proveexport.xls |
|Download:
http://www.thecodecage.com/forumz/attachment.php?attachmentid=104|
+-------------------------------------------------------------------+

--
eggpap

Excel 2003 on Vista HP System - can use VBA
------------------------------------------------------------------------
eggpap's Profile: http://www.thecodecage.com/forumz/member.php?userid=90
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=83143



eggpap[_26_]

Docmd.Transferdatabase error
 

You are right.

Now it is OK

Regards


--
eggpap

Excel 2003 on Vista HP System - can use VBA
------------------------------------------------------------------------
eggpap's Profile: http://www.thecodecage.com/forumz/member.php?userid=90
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=83143


Dave Peterson

Docmd.Transferdatabase error
 
Nope.

The code could have used:
Set oApp = nothing

Dave Patrick wrote:

Yes, I missed that but isn't the last assignment for oApp what's important?

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Dave Peterson" wrote:
I don't think so.

This is the line that's important:
Dim oApp As Access.Application
(removed the first few variables)

means early binding.

I wouldn't use this line with that declaration, but it's not important.
Set oApp = CreateObject("Access.Application")


--

Dave Peterson

Dave Patrick

Docmd.Transferdatabase error
 
Still not a good practice to add unnecessary clutter and confusion. :)


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"Dave Peterson" wrote:
Nope.

The code could have used:
Set oApp = nothing


Dave Patrick

Docmd.Transferdatabase error
 
You're welcome.


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"eggpap" wrote:

You are right.

Now it is OK

Regards


--
eggpap


Dave Peterson

Docmd.Transferdatabase error
 
I agree. And I would have used:

Dim oApp as object
Set oApp = CreateObject("Access.Application")
without a reference

or

Dim oApp As Access.Application
Set oApp = New Access.Application
with a reference

I think it leads to less confusion.



Dave Patrick wrote:

Still not a good practice to add unnecessary clutter and confusion. :)

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Dave Peterson" wrote:
Nope.

The code could have used:
Set oApp = nothing


--

Dave Peterson

Dave Patrick

Docmd.Transferdatabase error
 
Yepper

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"Dave Peterson" wrote:
I agree. And I would have used:

Dim oApp as object
Set oApp = CreateObject("Access.Application")
without a reference

or

Dim oApp As Access.Application
Set oApp = New Access.Application
with a reference

I think it leads to less confusion.



All times are GMT +1. The time now is 02:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com