I did find a solution.
First we place all found tables in a array. Query by BIBD: How can I get table names from an MS Access Database?
Then we read all the relationships from msysrelationships.
Now we order the tableNames by dependencies:
Function getDependencies(database)
Dim loopBit
Dim changeFound
loopBit = True
getTableNames(database)
Do While loopbit
changeCount = 0
DB_Connect database, "SELECT msysrelationships.szObject AS TableName, msysrelationships.szReferencedObject AS Dependency FROM msysrelationships ORDER BY msysrelationships.szObject;"
Do Until DB_EndRS = True
Dim tableNameIndex
Dim dependencyIndex
Dim tableParking
For index = 0 to UBound(tableArray)
If tableArray(index) = DB_Select("TableName") Then
tableNameIndex = index
Exit For
End If
Next
For index = 0 to UBound(tableArray)
If tableArray(index) = DB_Select("Dependency") Then
dependencyIndex = index
Exit For
End If
Next
If tableNameIndex < dependencyIndex Then
changeCount = changeCount + 1
tableParking = tableArray(tableNameIndex)
tableArray(tableNameIndex) = tableArray(dependencyIndex)
tableArray(dependencyIndex) = tableParking
End If
DB_MoveNext
Loop
DB_Disconnect
If changeCount = 0 Then
loopBit = false
End If
Loop
End Function
(I hope this is clear enough, please ask if I should provide extra info.)
This allows me to not know the data in the database while understanding the relationships within the database.
I hope this helps someone!