?
Solved

how to create a link table in VBA?

Posted on 2006-06-05
9
Medium Priority
?
1,365 Views
Last Modified: 2008-02-01
hi
my application (in mde format) uses advanced code and design.
i protect it with a designed login form.

I want create a link to my bank.mdb tables in my app.
when i open my app, it create the link in VBA.
can u help me?
thanks
0
Comment
Question by:yadafarin
  • 4
6 Comments
 
LVL 32

Expert Comment

by:jadedata
ID: 16835490
Hi yadafarin,
how will your app know where these linkable tables are located??

:)-j-
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 16835556
           DoCmd.TransferDatabase acLink, "Microsoft Access", "Path", acTable, "TableName", "TableName"

IS that what you're looking for?
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 16835575
Is the location of this bank.mdb going to be constant in relation to the application?
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:yadafarin
ID: 16836096
it's always in 'D:\Vazife'.
but my bank.mdb has an Access Password.
doesn't your code check password or...?
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 16836224
Create a link in your program using the FILE/GET EXTERNAL DATA/LINK TABLES



In Microsoft Access , if you import a table from another Microsoft Access database (.mdb) that's a linked table in that database, it will still be linked after you import it. That is, the link is imported, not the table itself.

If the database you're accessing requires a password, a dialog box appears when you run the macro. Type the password in this dialog box.

J

0
 
LVL 34

Accepted Solution

by:
jefftwilley earned 80 total points
ID: 16836357
If the other options don't work, here's a function you might be able to adapt that should do what you want.

1) I created a macro that runs the TransferDatabase thing I pasted above.
2) I'm exporting it into the bank.mdb
3) Using a shell command, I'm passing the userid and password and executing the macro I just exported.

Function Link_Remote_Files()
    On Error GoTo err_Link_Remote_Files
    Dim retval
' Export the link macro to Your bank.mdb
    DoCmd.TransferDatabase acExport, "Microsoft Access", "'D:\Vazife\bank.mdb", " & _
      "acMacro, "NAME OF MACRO TO LINK YOUR TABLES", "NAME OF MACRO TO LINK YOUR TABLES", False
' JT 12/16/2005 - This function executes the macro inside the bank.mdb database to link up the tables you want
    retval = Shell("C:\Program Files\Microsoft Office\ART\Office\MSACCESS.exe /User USERNAME /Pwd PASSWORD /Wrkgrp " &_
                 "Z:\System.mdw 'D:\Vazife\bank.mdb/X NAME OF MACRO TO LINK YOUR TABLES")
    MsgBox "Tables are now linked."
Exit Function
err_Link_Remote_Files:
            MsgBox "Function mod_Mexicali" & ".Link_Remote_Files." & vbCrLf & vbCrLf & "You have error number " & err & ".  " & err.Description
End Function
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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 describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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 …

839 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