Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about filling a combo box with a list of tables...... 1

Status
Not open for further replies.

GWhiz

Programmer
Dec 16, 1999
49
US
Hi, folks.

Thanks for any help you can offer.

I need to fill a combo box with a list of tables in the current database -- then select one of the tables (from the list in the combo box), assign its name to an object variable for use throughout the rest of the database.

List of tables should be able to be generated in real time (as opposed to creating a value list).

Anyone done anything like this before?

Thanks!!! [sig][/sig]
 
You could try using code to extract the table names from the Tables collection and compiling a Value list at Runtime...

I don't rightly know if this code works, but it can't be too far short.
Something like...

Code:
Sub AllTables()
    Dim obj As AccessObject, dbs As Object
    Dim strRowSource as String
    forms![Myform]![ComboBox].rowsourcetype = "Value List"
    forms![Myform]![ComboBox].rowsource = ""
    strRowSource = ""
    Set dbs = Application.CurrentData
    ' Search for open AccessObject objects in AllTables collection.
    For Each obj In dbs.AllTables
        if left(obj.name,4) <> &quot;MSYS&quot; then
            strRowSource = strRowSource & &quot;&quot;&quot; & obj.name & &quot;&quot;;&quot;
        endif
    Next obj
    forms![Myform]![ComboBox].RowSource = strRowSource
End Sub
[sig]<p>Phooey<br><a href=mailto:Andrew.j.harrison@capgemini.co.uk>Andrew.j.harrison@capgemini.co.uk</a><br>Otherwise known as Windy Bottom.[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top