Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2004, 12:27 AM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Link Table In Access 2000

Can i create linked tables in Access 2000 from SQL Server 2000, Oracle And VFP. Programatically. waitting.........

 
Old May 3rd, 2004, 05:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, Guru, you can.

via ODBC

I am a loud man with a very large hat. This means I am in charge
 
Old May 3rd, 2004, 05:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quick note to everyone else:
Before you go on about using ADO, note that the post said "linked tables"

I am a loud man with a very large hat. This means I am in charge
 
Old May 5th, 2004, 08:03 PM
Authorized User
 
Join Date: Oct 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Because this uses ADOX to link the table, be sure that "Microsoft ADO Ext 2.7 for DDL and Security" is checked ON as a reference. To verify this, go into your VBA editor and select Tools | References from the menu bar.

Here's how to link an table from an ODBC DSN using ADOX:

Public Function Link_ADO_DSN()
    Dim cat As New ADOX.Catalog
    Dim tbl As New ADOX.Table

    Dim strODBC_DSN As String
    Dim strODBC_TableName As String
    Dim strODBC_UserID As String
    Dim strODBC_Password As String

    strODBC_DSN = "ABC_Company"
    strODBC_TableName = "CUSTOMER"
    strODBC_UserID = "acct_receiv"
    strODBC_Password = "accounts"

    ' Set the ADO connection
    cat.ActiveConnection = CurrentProject.Connection

    ' Set the name and target for the table
    tbl.Name = strODBC_TableName
    Set tbl.ParentCatalog = cat

    ' Set the properties for the linked table
    tbl.Properties("Jet OLEDB:Create Link") = True
    tbl.Properties("Jet OLEDB:Link Provider String") = _
                   "ODBC;DSN=" & strODBC_DSN & ";" & _
                   "UID=" & strODBC_UserID & ";pwd=" & strODBC_Password & ";"
    tbl.Properties("Jet OLEDB:Cache Link Name/Password") = True
    tbl.Properties("Jet OLEDB:Remote Table Name") = strODBC_TableName

    ' Append the table to the collection
    cat.Tables.Append tbl

    Set tbl = Nothing
    Set cat = Nothing

End Function
 
Old May 6th, 2004, 12:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's a fair bit of code now isn't it?
Maybe something like:
Code:
DoCmd.TransferDatabase acLink, "ODBC Database", _
    "ODBC;DSN=DataSource1;UID=User2;PWD=www;LANGUAGE=us_english;" _
    & "DATABASE=pubs", acTable, "Authors", "dboAuthors"

would suffice

I am a loud man with a very large hat. This means I am in charge
 
Old January 24th, 2006, 09:39 AM
Registered User
 
Join Date: Jan 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

now i know why the aussie's won the world series of poker

 
Old March 16th, 2006, 06:22 PM
Registered User
 
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Leonard777
Default

What about linking to another secured Access Database. I cannot find how to include the password so that it does not prompt me for each table I link to?






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do record count for Link table in access ayazhoda Access VBA 0 April 16th, 2008 04:43 AM
can to link a ms access table to sql server? sugar SQL Server 2000 6 May 23rd, 2006 11:45 AM
Create table statement syntax error in access 2000 method Access 1 August 8th, 2005 02:10 AM
Access 2000 "Open ODBC SQL Table for Additions" cjdphlx Access VBA 3 July 18th, 2005 02:05 PM
Access and update linked SQL Server 2000 table Lizu Access 9 May 10th, 2004 12:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.