Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RecordSource and external MDB table

Posted on 2000-03-13
6
Medium Priority
?
366 Views
Last Modified: 2009-12-16
I want a form's RecordSource to be a table from an external MDB.  What is the syntax to achieve this?
0
Comment
Question by:rfedyk
[X]
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
6 Comments
 
LVL 7

Accepted Solution

by:
Believer earned 400 total points
ID: 2612728
There really isn't any "syntax."  What you need to do is link tables from the other database.  There's several ways to get this done, but I prefer to:
Right-click in the database window and select "Link tables..."  You will be prompted to designate the name of the database where the table(s) reside, then you can select which tables in that database you want to attach to this database.  Linked tables are generally treated the same as tables which are local to the database; you can put the tables in queries, bind forms to them, etc.
0
 
LVL 3

Expert Comment

by:MikeRenz
ID: 2612764
If you want to link the table programmatically you can do this:

 DoCmd.TransferDatabase acLink, "Microsoft Access", MyMDB, acTable, MyTableName1, MyTableName2


where MyMDB is a string representing a path to you databas, MyTableName1 is the name of the table linking to in your database, and MyTableName2 is what you want to name the table in your current database.

From there you can get your recordsource from you newly linked table.
0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2613632
On Open, run this code

Private Sub Form_Open(Cancel As Integer)

    DoCmd.TransferDatabase acLink, "Microsoft Access", "C:\SomePath\SomeDB.MDB", acTable, "<SourceTableName>", "<LocalTableName>"

End Sub


Then, if you only want to use the table, but not keep it,


Private Sub Form_Close()

    Dim d as Database
    Set d = CurrentDB
    d.tableDefs.Delete "<LocalTableName>"

End Sub


Brian


0
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.

 
LVL 1

Author Comment

by:rfedyk
ID: 2614359
Believer:

Thanks again

MikeRenz:

I'm going to use Believer's suggestion because there are over 70 tables from different MDB that are needed for this application.  I'll use your suggestion in the future so I'm going to post a "Points for MikeRenz" question.

BrianWren:

Sorry buddy,  Mike got there before you

0
 
LVL 3

Expert Comment

by:MikeRenz
ID: 2614416
I didn't realize you wanted every table.  Here is some good code for linking every table from another database...

Private Sub AttachAllTables(MyPath a String)
Dim MyDatabase As Database
Dim tdf As TableDef
Dim ReturnValue As Integer

   
    Set MyDatabase = DBEngine.OpenDatabase(MyPath) ' Open database.
    For Each tdf In MyDatabase.TableDefs
        If tdf.Attributes And dbSystemObject Then
        Else
            ReturnValue = SysCmd(SYSCMD_SETSTATUS, "Linking Table " & tdf.name)
            DoCmd.TransferDatabase acLink, "Microsoft Access", MyPath, acTable, tdf.name, tdf.name
        End If
    Next

    ReturnValue = SysCmd(SYSCMD_REMOVEMETER)
0
 
LVL 3

Expert Comment

by:MikeRenz
ID: 2614420
ooops...make that:       MyPath As String

and at the end add:      End Sub


sorry for not double checking before posting.
0

Featured Post

Independent Software Vendors: 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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

610 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