Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

MS Access

How do I link to data base using VBA Code.
0
PasqualeMarcantonio
Asked:
PasqualeMarcantonio
2 Solutions
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Here is the De-Facto standard:

Relink Access tables from code
http://www.mvps.org/access/tables/tbl0009.htm

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

Call the standard Windows File Open/Save dialog box
http://www.mvps.org/access/api/api0001.htm

mx
0
 
PasqualeMarcantonioAuthor Commented:
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.
0
 
als315Commented:
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"
0
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!

 
mstlwilliamsCommented:
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.

0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
There is no need to us ADODB to link to an Access MDB or ACCDB.

mx
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
<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.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Has this question been resolved?  Can we close the question ?

thx.mx
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
The author asked how to link tables with VBA. Both of these are correct, valid solutions:

http:#a35059939
http:#a35060023

Suggest you split the points between them
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
I concur with LSM ...

mx
0
 
South ModModeratorCommented:
All,
 
Following an 'Objection' by LSMConsulting (at http://www.experts-exchange.com/Q_27193677.html) 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,
 
SouthMod
Community Support Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now