Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 22nd, 2005, 11:46 AM
Friend of Wrox
 
Join Date: Mar 2005
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old June 22nd, 2005, 12:26 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:53 AM.


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