Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem scanning over all non system table

Status
Not open for further replies.

JASONE25

Technical User
Jun 23, 2005
54
NL
i wrote a vba code that supposed to
go find all non system tables in access 2000 db
and generate corresponded create table statements for them.
Unfortunately when i run the program it misses one of the
tables called committee members and also uses one of
table names 2 time.Furthermore, instead of using table names it
uses first columns of each table in generating table name for createing table statement.
I be happy if some expert help me fix this bug in my vba program.Thanks




Code:
Private Sub CreateTableButton_Click()
    Dim T As TableDef
    Dim db As Database, cont As String
    Set db = CurrentDb()
    For Each T In db.TableDefs
        If Left(T.Name, 4) <> "MSys" Then
           ' 'If T.Name = Me.ComboBox Then
                pk = Left(GetPK(T, db), InStr(1, GetPK(T, db), "<-") - 1)
                
                cont = cont & ShowFields(T.Name) & vbCrLf & " primary key " & pk & vbCrLf & vbCrLf
               ''MsgBox ShowFields(T.Name) & vbCrLf & " primary key " & pk & vbCrLf & vbCrLf
            ''End If
        End If
    Next T
    MsgBox cont
    Call createTextFile("C:\createTableStatements.txt", cont)
     
End Sub
 
I ran your code and it finds all of the tables I have constructed so I cannot figure out why it would return one table twice. From what I see, ShowFields() is supposed to append all of the field names in the statement, but I do not see where you append the "Create table" & tablename part in your cont variable. It will be difficult to debug this without knowing exaclty waht ShowFields() does and returns.

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top