Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cataclog Column Properties

Status
Not open for further replies.

gavjb

Technical User
Jul 5, 2005
67
GB
Hi,

Can some please help me as I am trying to set some properties when Creating a table (eg cat.Columns("ID").Properties("AutoIncrement")), but MS Help is its normal useless and sending me round in circles, does anyone know how I can get a list of all column Properties availble. In particular I am looking for the setting to set a column not to be required.

Thanks,



Gavin,
 
I managed to find the code on the Net, here it is for anyone else who had this problem

Code:
Private Function CreateTable() As Boolean
' Summary  : This function will create a table for Audit Log
' History  : [Gavin Blackford] 22/03/2006     Created
'------------------------------------------------------------------------
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table

    ' Create Connection to Database
    cat.ActiveConnection = CurrentProject.Connection

    ' Create Table
    With tbl
        .Name = AuditTable
        Set .ParentCatalog = cat
        .Columns.Append "ID", adInteger
        .Columns("ID").Properties("AutoIncrement") = True
        .Columns.Append "User", adVarWChar, 25
        .Columns.Append "DateTime", adDate
        .Columns.Append "Object", adVarWChar, 255
        .Columns.Append "Action", adVarWChar, 255
        .Columns.Append "DataKey", adVarWChar, 255
        ![DataKey].Properties("Nullable") = True
        
    End With
    
    cat.Tables.Append tbl
End Function

the .Properties("Nullable") = True sets the required (in Designer) to false
 
Another simple way:
DoCmd.RunSQL "CREATE TABLE AuditTable (" _
& "ID COUNTER PRIMARY KEY,[User] CHAR(25) NOT NULL,[DateTime] DateTime NOT NULL" _
& ",Object CHAR(255) NOT NULL,Action CHAR(255) NOT NULL,DataKey CHAR(255))"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top