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 June 22nd, 2005, 11:46 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with this insert statment in vba

Hi guys i got vba code that suppose to write table name ,column name , rquired ,feild type and feild size
to an external db. The first part of this code write tables naem to external db and it is working well.
I get the following error when i press the button on my form :
Code:
Run-time error '424':
Object required
and when i click on debut it points to this part with yellow collor.

Code:
 metadb.Execute " Insert Into SysColumns(tablename,columnname,required,type,lenght) " & _
    " Values ('" & TableDef.Name & "','" & Feild.Name & "'," & Feild.Required & ",'" & FieldType(Feild.Type) & "'," & Feild.Size & ")"
     
I be happy if some one help me fix this erro.Thanks
my complete code

Code:
Sub InsertSystemCatalogPopulation(db As Database, metadb As Database)

'''now locating all the non system tables in current db  and then writing it
'''to systables table
For Each tbl In db.TableDefs

''' excluding the system tables
        If Left(tbl.Name, 4) <> "MSys" Then
        ''' writing the tables name to systables

            metadb.Execute " Insert Into SysTables(TableName) Values ('" & tbl.Name & "')"
        End If
    Next tbl

    MsgBox (" All tables names coped to systables system cataloge ")

  '''###################################################################################

    ''' now we go find all non syste feilds in the current db and then writing ity
    '''  to syscolumns

    For Each TableDef In CurrentDb.TableDefs
'''this if statment remove the system feilds
 If Left(TableDef.Name, 4) <> "Msys" Then
   For Each Field In TableDef.Fields
     
    metadb.Execute " Insert Into SysColumns(tablename,columnname,required,type,lenght) " & _
    " Values ('" & TableDef.Name & "','" & Field.Name & "'," & Field.Required & ",'" & FieldType(Field.Type) & "'," & Field.Size & ")"
     
    Next Field
  End If
Next TableDef

End Sub




Function FieldType(intType As Integer) As String

    Select Case intType
        Case dbBoolean
            FieldType = "dbBoolean"
        Case dbByte
            FieldType = "dbByte"
        Case dbInteger
            FieldType = "dbInteger"
        Case dbLong
            FieldType = "dbLong"
        Case dbCurrency
            FieldType = "dbCurrency"
        Case dbSingle
            FieldType = "dbSingle"
        Case dbDouble
            FieldType = "dbDouble"
        Case dbDate
            FieldType = "dbDate"
        Case dbText
            FieldType = "dbText"
        Case dbLongBinary
            FieldType = "dbLongBinary"
        Case dbMemo
            FieldType = "dbMemo"
        Case dbGUID
            FieldType = "dbGUID"
    End Select

End Function
 
Old June 22nd, 2005, 12:26 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

  Well I don't know if it is this simple, but you mispelled "length" (also "copied" and "catalog") :D

   Also, you are using DAO. Do you have the reference selected and moved above ADO in the list?

HTH


mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
insert & update statment problem (sql express) abdrabaa C# 2 July 15th, 2007 05:54 AM
Help with SQL Insert statement in VBA Code ausmoran Access VBA 1 December 28th, 2006 06:16 PM
PROBLEM WITH INSERT STATMENT sanjeet General .NET 1 February 4th, 2005 09:39 AM
insert a row with vba Butch Excel VBA 1 December 21st, 2004 12:35 PM
Insert Image Using VBA timmaher Excel VBA 1 September 3rd, 2004 10:54 AM





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