Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

problem with this insert statment in vba

Options
  • 22-06-2005 5:57pm
    #1
    Closed Accounts Posts: 1


    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 :
    
    Run-time error '424':
    
    Object required
    
    

    and when i click on debut it points to this part with yellow collor.
    
     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
    
    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 & "','" & Feild.Name & "'," & Feild.Required & ",'" & FieldType(Feild.Type) & "'," & Feild.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
    
    
    


Comments

  • Closed Accounts Posts: 1,746 ✭✭✭0utshined


    method wrote:
    and when i click on debut it points to this part with yellow collor.
    
     metadb.Execute " Insert Into SysColumns(tablename,columnname,required,type,[B]lenght[/B]) " & _
        " Values ('" & TableDef.Name & "','" & [B]Feild[/B].Name & "'," & [B]Feild[/B].Required & ",'" & FieldType([B]Feild[/B].Type) & "'," & [B]Feild[/B].Size & ")"
         
    

    Sorry don't have time to look at it now but check the spelling for the bits I've highlighted.


  • Registered Users Posts: 2,781 ✭✭✭amen


    as an aside is the MS SQL ?
    if so why are you inserting into SysColumns ?


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I think its Access.


Advertisement