Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function basGetInfo()
'Michael Red 7/1/2003 for Tek-Tips thread700-589833, "Toledo"
'Pseudo Tested:
'Requirements:
' A table [tblMyDbs] with the single field [dbName] as Text (length to suit you needs) _
The entry is the full path and name of the database file (.MDB) where you want to know _
(i.e. collect) the names and other info re the linked tables in THAT db
' A Table [MyLinkInfo] with fields: _
[dbName] as Text, length to suit (the [ForeginName] from the DB) _
[Flags] as Text, length to suit - suggest 20 (the flag field from from the DB) _
[Name] as Text, Length to suit The Name filed fro the db. Theis is the "Name" _
used in the db to reference the linked object (table) in the DB
' Of course anyone with this code can easily change / adapt these to their needs, the above are _
for use with the UN-Modified code shown here.
Dim WrkSpc As DAO.Workspace
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim dbsLocal As DAO.Database
Dim rstLocal As DAO.Recordset
Dim strSql As String
Dim strSqlIns As String
Dim strSqlSel As String
Dim strSqlFrm As String
Dim strSqlWhr As String
Dim strSqlGrp As String
Dim strSqlHvg As String
Dim strSqlOrBy As String
Dim strSqlEnd As String
Dim Quo As String * 1
Dim Idx As Integer
Quo = Chr(34)
Set dbsLocal = CurrentDb
Set WrkSpc = CreateWorkspace("", "admin", "", dbUseJet)
Set rstLocal = dbsLocal.OpenRecordset("tblMyDbs", dbOpenDynaset)
On Error GoTo ErrExit
While Not (rstLocal.EOF)
Set dbs = WrkSpc.OpenDatabase(rstLocal!dbName, False)
strSqlIns = "Insert InTo MyLinkInfo " & _
"(dbName, Flags, ForeignName, Name, LinkDbName) "
strSqlSel = "Select " & _
"Database, " & _
"Flags, " & _
"Name, " & _
"ForeignName, " & _
Quo & rstLocal!dbName & Quo & " as LinkDbName "
strSqlFrm = "FROM " & rstLocal!dbName & ".MSysObjects "
strSqlWhr = "Where " & _
"(MSysObjects.Name Not Like " & Quo & "MSys*" & Quo & _
" and " & _
"MSysObjects.Type = 6) "
strSqlGrp = "GROUP BY " & _
"Database, " & _
"Flags, " & _
"Name, " & _
"ForeignName "
strSqlHvg = "HAVING ((Database) Is Not Null) "
strSqlOrBy = "ORDER BY Database"
strSqlEnd = ";"
strSql = strSqlSel & strSqlFrm & strSqlWhr & _
strSqlGrp & strSqlHvg & strSqlOrBy & strSqlEnd
'******* This BLOCK of code is just for convenince in testing. It CAN (and Should) be removed for Production
Set rst = dbs.OpenRecordset(strSql, dbOpenDynaset)
While Not rst.EOF
Debug.Print rst!Name
rst.MoveNext
Wend
rstLocal.MoveNext
'*******End Testing Block
strSql = strSqlIns & strSqlSel & strSqlFrm & strSqlWhr & _
strSqlGrp & strSqlHvg & strSqlOrBy & strSqlEnd
dbsLocal.Execute strSql
Wend
GoTo NormExit
ErrExit:
Stop
NormExit:
End Function