|
-
Jun 22nd, 2005, 11:49 AM
#1
Thread Starter
Frenzied Member
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 & "','" & 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
-
Jun 22nd, 2005, 12:28 PM
#2
Re: problem with this insert statment in vba
Why are you trying to write to the system tables telling them that there are tables in the db? If you create the tables it
will automatically write to the systables the tables and their schema.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 22nd, 2005, 12:42 PM
#3
Thread Starter
Frenzied Member
Re: problem with this insert statment in vba
 Originally Posted by RobDog888
Why are you trying to write to the system tables telling them that there are tables in the db? If you create the tables it
will automatically write to the systables the tables and their schema.
well it is systable in external db that my code generate that systable!
-
Jun 22nd, 2005, 01:07 PM
#4
Re: problem with this insert statment in vba
Oh, ok. I was thinking MSYS tables.
You have a mispelled object word - Feild.Name.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 22nd, 2005, 01:12 PM
#5
Thread Starter
Frenzied Member
Re: problem with this insert statment in vba
 Originally Posted by RobDog888
Oh, ok. I was thinking MSYS tables.
You have a mispelled object word - Feild.Name.
opss . thank u i fixed it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|