problem understaing this vba code!

Joined
Jun 30, 2005
Messages
59
Reaction score
0
Hi all. I got a access vba 2000 code that i hardly understand what some of its part doing.
i need to learn this since i want to learn how to refrence these system tables.
I be happy if some expert explain to me what these part does.Thanks

part1:

Code:
  Set rsMetadb = MetaDB.OpenRecordset("SysKeys")
part2:

Code:
For Each idx In tbl.Indexes
            bUpdate = False
            rsMetadb.AddNew
            rsMetadb("Tablename") = tbl.Name
         If idx.Primary = True Or idx.Unique = True Then rsMetadb("Keyname") = idx.Name
part3:

Code:
  If bUpdate Then rsMetadb.Update
part4:

Code:
  rsMetadb("Keytype") = "PRIMARY"
complete code:

Code:
 Dim bUpdate, ref As String
  Dim i As Integer


  Set rsMetadb = MetaDB.OpenRecordset("SysKeys")

  For Each tbl In db.TableDefs
    If Left(tbl.Name, 4) <> "MSys" Then
     For Each idx In tbl.Indexes
            bUpdate = False
            rsMetadb.AddNew
            rsMetadb("Tablename") = tbl.Name
         If idx.Primary = True Or idx.Unique = True Then rsMetadb("Keyname") = idx.Name
       'Check primary key
         If idx.Primary = True Then
            rsMetadb("Keytype") = "PRIMARY"
            bUpdate = True
         Else
       'Check Alternate key
           If idx.Unique = True And idx.Primary = False And idx.Foreign = False Then
            rsMetadb("Keytype") = "ALTERNATIVE"
            bUpdate = True
           End If
         End If
       If bUpdate Then rsMetadb.Update
     Next idx
    End If
  Next tbl
rsMetadb.Close
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top