Solved

Filling a list box with data from other database.

Posted on 2000-04-06
1
161 Views
Last Modified: 2011-09-20
I've got a database that has a form that needs to display the results of a query against another access database.  Currently I do this by opening the other database running the query and then copy the results into the rowsource property of the list box, after clicking values.  This works, however lately the query result got bigger and rowsource is limited to 2,000 characters.  
What is the proper way of doing this?  I'm assuming I'll need to link the foreign table but since the other database is user's choice I'll need to do this in code.  Also I'll need to delete the link later.
0
Comment
Question by:calvinrsmith
1 Comment
 
LVL 3

Accepted Solution

by:
MikeRenz earned 50 total points
ID: 2692264
Here is some code for linking all tables from a specified database (mypath = the path to the database) and also for deleting the links to those tables.  You can modify it to only link in certain tables by ripping out the loops and exchanging tdf.name with the name of the table you want to link in.

After you have your link then just join the two tables being compared in a query...joining on the similar ids or whatever you are trying to accomplish.


Private Sub DeleteAttachedTables(MyPath as 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, "Deleting Table " & tdf.name)
            DoCmd.DeleteObject acTable, tdf.name
        End If
    Next

    ReturnValue = SysCmd(SYSCMD_REMOVEMETER)

End Sub

Private Sub ReAttachTable(MyPath As 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, "Attaching Table " & tdf.name)
            DoCmd.TransferDatabase acLink, "Microsoft Access", MyPath, acTable, tdf.name, tdf.name
        End If
    Next

    ReturnValue = SysCmd(SYSCMD_REMOVEMETER)

End Sub
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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