Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 7th, 2005, 10:57 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem understaing this vba code!

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

 
Old August 8th, 2005, 02:58 AM
Friend of Wrox
 
Join Date: Jul 2005
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Without all the code it is hard to say exactly.

I appears to be reading the table Definitions and storing then table names and index names.



Boyd
"Hi Tech Coach"
Access Based Accounting/Business Solutions developer.
http://www.officeprogramming.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with VBA code.. need help arian29 VB Databases Basics 1 November 29th, 2008 07:44 PM
VBA Code D0MiN0 Access VBA 2 March 31st, 2008 03:55 AM
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Help with VBA Code KevinN Excel VBA 1 April 22nd, 2005 06:50 AM
VBA code desprate Access VBA 7 April 12th, 2005 08:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.