how to create a link table in VBA?

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
yadafarinAsked:
Who is Participating?
 
jefftwilleyCommented:
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
 
jadedataMS Access Systems CreatorCommented:
Hi yadafarin,
how will your app know where these linkable tables are located??

:)-j-
0
 
jefftwilleyCommented:
           DoCmd.TransferDatabase acLink, "Microsoft Access", "Path", acTable, "TableName", "TableName"

IS that what you're looking for?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
jefftwilleyCommented:
Is the location of this bank.mdb going to be constant in relation to the application?
0
 
yadafarinAuthor Commented:
it's always in 'D:\Vazife'.
but my bank.mdb has an Access Password.
doesn't your code check password or...?
0
 
jefftwilleyCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.