PC Review


Reply
Thread Tools Rate Thread

DoCmd.TransferDatabase acExport to SQL server 2005

 
 
TL
Guest
Posts: n/a
 
      2nd Mar 2010
All,
I am trying to export a table from an Access 2007 database to a SQL server
2005 database. However I can not get the table to export to the correct
schema. it always goes to the dbo schema. Below is the code I am running.
When I run the table shows up in SQL as dbo.[schema.SQL_Tableusername] and I
need it to be schema.SQL_Tableuser

Any help would be helpful

Private Sub Command7_Click()
Dim db As Database
Dim username As String
Dim tablename As String

Set db = CurrentDb

username = Environ("USERNAME")
username = Replace(username, ".", "")
tablename = "" & "SQL_Table" & username & ""




On Error GoTo ErrorHandler2
DoCmd.TransferDatabase acExport, "ODBC Database", _
"ODBC;DSN=PAWCHDPARTDEV01;UID=MyUserID;PWD=MyPassword;LANGUAGE=us_english;" _
& "DATABASE=DPART_P008", acTable, "tbl_accounts", "schema." & tablename





'db.Execute (execLe10)

MsgBox "Done", vbInformation
Exit Sub
ErrorHandler1:
MsgBox "Failed1", vbInformation
ErrorHandler2:
MsgBox "Failed2", vbInformation

End Sub

 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      2nd Mar 2010
Hi,
I guess that TransferDatabase exports to default user's schema, perhaps you
can try to change it before export and then put it back
Another approach - export to temp table and then move to required table
using Insert Into

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com


"TL" <(E-Mail Removed)> wrote in message
news:7E390686-DE77-44CE-A028-(E-Mail Removed)...
> All,
> I am trying to export a table from an Access 2007 database to a SQL server
> 2005 database. However I can not get the table to export to the correct
> schema. it always goes to the dbo schema. Below is the code I am running.
> When I run the table shows up in SQL as dbo.[schema.SQL_Tableusername] and
> I
> need it to be schema.SQL_Tableuser
>
> Any help would be helpful
>
> Private Sub Command7_Click()
> Dim db As Database
> Dim username As String
> Dim tablename As String
>
> Set db = CurrentDb
>
> username = Environ("USERNAME")
> username = Replace(username, ".", "")
> tablename = "" & "SQL_Table" & username & ""
>
>
>
>
> On Error GoTo ErrorHandler2
> DoCmd.TransferDatabase acExport, "ODBC Database", _
> "ODBC;DSN=PAWCHDPARTDEV01;UID=MyUserID;PWD=MyPassword;LANGUAGE=us_english;"
> _
> & "DATABASE=DPART_P008", acTable, "tbl_accounts", "schema." & tablename
>
>
>
>
>
> 'db.Execute (execLe10)
>
> MsgBox "Done", vbInformation
> Exit Sub
> ErrorHandler1:
> MsgBox "Failed1", vbInformation
> ErrorHandler2:
> MsgBox "Failed2", vbInformation
>
> End Sub
>

 
Reply With Quote
 
TL
Guest
Posts: n/a
 
      2nd Mar 2010
I tried the default schema but that did not work. I will try the temp table
now.

"Alex Dybenko" wrote:

> Hi,
> I guess that TransferDatabase exports to default user's schema, perhaps you
> can try to change it before export and then put it back
> Another approach - export to temp table and then move to required table
> using Insert Into
>
> --
> Best regards,
> ___________
> Alex Dybenko (MVP)
> http://accessblog.net
> http://www.PointLtd.com
>
>
> "TL" <(E-Mail Removed)> wrote in message
> news:7E390686-DE77-44CE-A028-(E-Mail Removed)...
> > All,
> > I am trying to export a table from an Access 2007 database to a SQL server
> > 2005 database. However I can not get the table to export to the correct
> > schema. it always goes to the dbo schema. Below is the code I am running.
> > When I run the table shows up in SQL as dbo.[schema.SQL_Tableusername] and
> > I
> > need it to be schema.SQL_Tableuser
> >
> > Any help would be helpful
> >
> > Private Sub Command7_Click()
> > Dim db As Database
> > Dim username As String
> > Dim tablename As String
> >
> > Set db = CurrentDb
> >
> > username = Environ("USERNAME")
> > username = Replace(username, ".", "")
> > tablename = "" & "SQL_Table" & username & ""
> >
> >
> >
> >
> > On Error GoTo ErrorHandler2
> > DoCmd.TransferDatabase acExport, "ODBC Database", _
> > "ODBC;DSN=PAWCHDPARTDEV01;UID=MyUserID;PWD=MyPassword;LANGUAGE=us_english;"
> > _
> > & "DATABASE=DPART_P008", acTable, "tbl_accounts", "schema." & tablename
> >
> >
> >
> >
> >
> > 'db.Execute (execLe10)
> >
> > MsgBox "Done", vbInformation
> > Exit Sub
> > ErrorHandler1:
> > MsgBox "Failed1", vbInformation
> > ErrorHandler2:
> > MsgBox "Failed2", vbInformation
> >
> > End Sub
> >

> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Docmd.TransferDatabase acExport file name problem Sunny Microsoft Access 5 26th Jun 2009 11:44 AM
docmd.transferdatabase access 2003 to sql 2005 Chris Kemp Microsoft Access External Data 2 11th Aug 2007 09:59 PM
DoCmd.TransferSpreadsheet acExport....... =?Utf-8?B?Qm9iIEJhcm5lcw==?= Microsoft Access 2 26th Jun 2007 08:50 PM
Help with DoCmd.TransferDatabase, acExport... =?Utf-8?B?Vi5QLg==?= Microsoft Access VBA Modules 0 26th Jun 2006 07:11 PM
TRANSFERDATABASE acEXPORT QUESTION =?Utf-8?B?Q0o=?= Microsoft Access External Data 0 18th Jul 2005 11:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:53 PM.