G Gerard wrote:
Hello
I am creating a wizard so a user can import data from other type of
databases (DBase IV, Paradox etc...) into an Access mdb.
The first step would require the user to choose the type and path of
database.
I would then like to display a list of tables in that database available
for import.
And that is where I am not quite sure how to do this especially with
other type
of databases.
With an mdb database I would use:
Set MyImpDB = DBEngine.OpenDatabase(path)
For Each defTbl in MyImpDB.TableDefs
'Get defTbl.Name and add to list box
Next defTbl
Any thoughts?
Thanks
G Gerard
Open the Listbox's property sheet, select Data tab, go to the Row Source
Type row, click on it, and press F1.
From help: "To set the RowSourceType property to a user-defined
function, enter the name of the function."
Look in the help doc for a user-defined function. The help topic I am
looking at is "RowSourceType Property (User-Defined Function) — Code
Argument Values". Look at the code example.
Here is one I found in the example
Function ListMDBs(fld As Control, id As Variant, row As Variant, col As
Variant, code As Variant) As Variant
Static dbs(127) As String, Entries As Integer
Dim ReturnVal As Variant
ReturnVal = Null
Select Case code
Case acLBInitialize
Entries = 0
dbs(Entries ) = Dir("*.MDB")
Do Until dbs(Entries) = "" Or Entries >= 127
Entries = Entries+1
dbs(Entries) = Dir
Loop
ReturnVal = Entries
Case acLBOpen ReturnVal = Timer Case acLBGetRowCount
ReturnVal = Entries
Case acLBGetColumnCount ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWidth ' Column width.
ReturnVal = -1
Case acLBGetValue ' Get data.
ReturnVal = dbs(row)
Case acLBEnd
Erase dbs
End Select
ListMDBs = ReturnVal
End Function
You could use the above one, except for the Initialize where you'd
change the MDB refs to tabledef names (and remove the limitation of 127
mdbs).
Now in the RowSourceType you would enter
ListMDBs
You don't precede the function with an = sign.