Hey Akshita,
I have a good example for you. I removed the error handling and made the tables more generic for you but you'll get the drift. If you just place the code in your project it should work. just remember to reference the ADO type library and change the Data Source.
[tt]
Public Sub CreateDB()
Dim cat As New adox.Catalog
Dim tbl As New Table
Dim keyIndex As New adox.Index
cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\DB1.MDB"
' Open the Catalog.
cat.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\DB1.MDB"
'Add a new table to the newly created database
'table Customers
With tbl
'Add fields
.Name = "Customers"
.Columns.Append "CustName", adWChar, 25
.Columns.Append "CustID", adInteger, 6
.Columns.Append "ActiveCustomer", adBoolean, 1
.Columns.Append "Address", adWChar, 255
.Columns.Append "Phone", adWChar, 15
.Columns("Phone"

.Attributes = adColNullable
End With
keyIndex.Name = "CustNameIndex"
keyIndex.Unique = True
keyIndex.Columns.Append "CustName"
tbl.Indexes.Append keyIndex
cat.Tables.Append tbl
Set tbl = Nothing
Set keyIndex = Nothing
'table Orders
With tbl
'Add fields
.Name = "Orders"
.Columns.Append "OrderID", adInteger, 6
.Columns.Append "SysDT", adDate, 16
.Columns.Append "CustID", adInteger, 6
.Columns.Append "Details", adLongVarWChar, 2048
.Columns.Append "SalePrice", adInteger, 25
.Columns("SalePrice"

.Attributes = adColNullable
End With
keyIndex.Name = "OrderIDIndex"
keyIndex.Unique = True
keyIndex.Columns.Append "OrderID"
tbl.Indexes.Append keyIndex
Set keyIndex = Nothing
keyIndex.Name = "CustIDIndex"
keyIndex.Unique = True
keyIndex.Columns.Append "CustID"
tbl.Indexes.Append keyIndex
Set keyIndex = Nothing
keyIndex.Name = "SysDTIndex"
keyIndex.Unique = True
keyIndex.Columns.Append "SysDT"
tbl.Indexes.Append keyIndex
cat.Tables.Append tbl
'Clean up
Set cat = Nothing
Set tbl = Nothing
Set keyIndex = Nothing
End Sub[/tt]
Craig, mailto:sander@cogeco.ca
"Procrastination is the art of keeping up with yesterday."
I hope my post was helpful!!!