I use the following function to populate a listbox on an
export form which allows the user to see tables, queries
or reports in a listbox according to their selection
(sent in as pObjectType).
Reply if you still have problems.
Regards...
==
Public Function ListObjects(pObjectType As String)
'For the relevant type of object (query/table/report)
'list them in the listbox on the form
On Error GoTo ListObjects_Err
Dim Db As Database
Dim vList As String
Dim vDocuments As Document
Dim i As Integer
Set Db = DBEngine.Workspaces(0).Databases(0)
Select Case pObjectType
Case "Queries"
Db.QueryDefs.Refresh
If Db.QueryDefs.count = 0 Then
MsgBox "No " & pObjectType & " exist in the database"
Else
For i = 0 To Db.QueryDefs.count - 1
vList = vList & Db.QueryDefs(i).Name & ";"
End If
Next i
End If
Case "Tables"
If Db.TableDefs.count = 0 Then
MsgBox "No " & pObjectType & " exist in the database"
Else
For i = 0 To Db.TableDefs.count - 1
If Not Left(Db.TableDefs(i).Name, 4) = "MSys" Then
vList = vList & Db.TableDefs(i).Name & ";"
End If
Next i
End If
Case "Reports"
If Db.Containers(pObjectType).Documents.count = 0 Then
MsgBox "No " & pObjectType & " exist in the database"
Else
With Db.Containers(pObjectType)
For Each vDocuments In .Documents
vList = vList & vDocuments.Name & ";"
End If
Next vDocuments
End With
End If
End Select
'Set the relevant form fields requirements
Forms![frm_ExportForm]![lst_Originator].ColumnWidths = "2 in"
Forms![frm_ExportForm]![lst_Originator].ColumnCount = 1
Forms![frm_ExportForm]![lst_Originator].RowSourceType = "Value List"
Forms![frm_ExportForm]![lst_Originator].RowSource = vList
Forms![frm_ExportForm]![fld_Option] = pObjectType
Forms![frm_ExportForm]![fld_OriginatorLabel].Caption = " "
Forms![frm_ExportForm]![fld_OriginatorLabel].Caption = "Select from " & pObjectType
ListObjects_Exit:
On Error Resume Next
Exit Function
ListObjects_Err:
Call ut_Bug(Err.Description, Err.Number, Erl(), Application.CurrentObjectName, "ListObjects"

Resume ListObjects_Exit
End Function