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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a list of tables on a form???

Status
Not open for further replies.

flip79

MIS
Jul 5, 2002
23
0
0
US
I have found some code to create a dynamic list of tables in Access on a form, but I keep getting error #438 "object doesn't support this property or method". Do I need to add a reference from the reference library? If so, which one?

Here's the code in case it helps.

Private Sub Form_Current()
Dim objAO As AccessObject
Dim objCP As Object
Dim strValues As String

Set objCP = Application.CurrentProject

For Each objAO In objCP.AllTables
strValues = strValues & objAO.Name & ";"
Next objAO

'Set combo box row source to strValues
cboTableListImport.RowSource = strValues
End Sub


Thanks for any feedback!!!
 
This works for me ...

Public Function FullTableList() As String
Dim AO As AccessObject
Dim S As String
For Each AO In Application.CurrentData.AllTables
If S <> &quot;&quot; Then S = S & &quot;;&quot;
S = S & &quot;&quot;&quot;&quot; & AO.Name & &quot;&quot;&quot;&quot;
Next AO
FullTableList = S
End Function

You don't state where the error occurs.
The &quot;&quot;&quot;&quot; bit will enclose each table name in quote marks - which you will need if you are setting a value-based listbox.
 
Thanks a lot. I'm still wondering why the code I posted doesn't work. BTW, the error occurs whenever the form is opened (I put the code in the onCurrent event).

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top