MS Access

Posted on 2011-03-07
Last Modified: 2012-05-11
How do I link to data base using VBA Code.
Question by:PasqualeMarcantonio
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 75

Accepted Solution

DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 35059939
Here is the De-Facto standard:

Relink Access tables from code

You will need this also (referenced in the KB):

Call the standard Windows File Open/Save dialog box


Author Comment

ID: 35060013
I plan to open a form, test for data in a table, if the table is not found then link to the data base using VBA Code.
LVL 40

Assisted Solution

als315 earned 250 total points
ID: 35060023
Example from Access help:
DoCmd.TransferDatabase acLink, "ODBC Database", _
    "ODBC;DSN=DataSource1;UID=User2;PWD=www;LANGUAGE=us_english;" _
    & "DATABASE=pubs", acTable, "Authors", "dboAuthors"

DoCmd.TransferDatabase acLink, "Microsoft Access", _
    "C:\My Documents\NWSales.mdb", acTable, "MyTable"
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.


Expert Comment

ID: 35060024
If you want to link to a Microsoft Access database from a standalone VB program, you can use ADODB.  The connection string will need to be specific for Access.  I'm looking for a sample and will post it when I find it.
You can also set up an ODBC connection for the MS Access database and use that in your VB for connecting.

LVL 75
ID: 35060085
There is no need to us ADODB to link to an Access MDB or ACCDB.

LVL 84
ID: 35060296
<There is no need to us ADODB to link to an Access MDB or ACCDB.>

If you mean to link tables then you're right - DAO is much easier to work with if the goal is to build linked tables from within Access.

If the OP wishes to connect to an Access database from another environment (like VB or ASP) there's nothing wrong with using ADO. In many cases it's preferable to build a connection to the Database using ADO and then work with that connection, depending on what you want to accomplish.
LVL 75
ID: 35871357
Has this question been resolved?  Can we close the question ?
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 36175847
I've requested that this question be deleted for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
LVL 84
ID: 36175848
The author asked how to link tables with VBA. Both of these are correct, valid solutions:


Suggest you split the points between them
LVL 75
ID: 36176996
I concur with LSM ...


Expert Comment

by:South Mod
ID: 36230702
Following an 'Objection' by LSMConsulting (at to the intended closure of this question, it has been reviewed by at least one Moderator and is being closed as recommended by the Expert.
At this point I am going to re-start the auto-close procedure.
Thank you,
Community Support Moderator

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create a varying recordset 5 54
Automate an Oracle update in Excel 7 70
Oracle SQL-Queries on a RAC Database 3 48
Access 2003, percentage between two fields 18 24
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question