I am using the following module code to display in a List Box all
attached tables that start with tblProducts i.e. tblProductsSpain or
tblProductsFrance etc
I have other code which enables the user to enter a new table name,
the code then creates the table in the attached back end database and
automatically links it to the front end.
My problem is that the list box does not display the new tables until
I close the program and restart it. Requery has no effect, is there a
way of forcing a refresh?
Thanks
Patrick
Function ListAllTables(fld As Control, ID As Long, row As _
Long, col As Long, Code As Integer)
Dim Db As Database
Dim tbdf As TableDef
Static tbls(256) As String
Static Entries As Integer
Dim i As Integer
Dim ReturnVal
ReturnVal = Null
Select Case Code
Case LB_INITIALIZE ' Initialize database.
Set Db = DBEngine.Workspaces(0).Databases(0)
Entries = 0
For i = 0 To Db.TableDefs.Count - 1
If Left(Db.TableDefs(i).Name, 11) = "tblProducts" And
Db.TableDefs(i).Name <> "tblProducts" And Db.TableDefs(i).Name <>
"tblProductsHTML" And Db.TableDefs(i).Name <>
"tblProductsEndOfYearArchive" Then
tbls(Entries) = Db.TableDefs(i).Name
Entries = Entries + 1
End If
Next i
ReturnVal = Entries
Case LB_OPEN ' Open.
ReturnVal = Timer ' Unique ID number for control.
Case LB_GETROWCOUNT ' Number of rows.
ReturnVal = Entries
Case LB_GETCOLUMNCOUNT ' Number of columns.
ReturnVal = 1
Case LB_GETCOLUMNWIDTH ' Column width.
ReturnVal = -1 ' Use the default width.
Case LB_GETVALUE ' Get the data.
If Left(tbls(row), 11) = "tblProducts" Then
ReturnVal = tbls(row)
End If
Case LB_END ' End.
For Entries = 0 To 256
tbls(Entries) = ""
Next
End Select
ListAllTables = ReturnVal
End Function