write to "Description" col in Access 
Author Message
 write to "Description" col in Access
how to programmatically write to the "Description" column in an Access
design-view of a table . . . ?


Sun, 11 Jan 2004 01:01:28 GMT
 write to "Description" col in Access

Use ADOX to set the value... The example below adds a
table to the Northwind database and sets the Description
of the fields.

Create a new VB PRoject

Add the following references to the project

Microsoft ActiveX Data Objects 2.6 Library
Microsoft ADO Ext. 2.6 for DDL and Security

Copy code into form

------------------Code Begins ------------------------
Private Sub Form_Load()

   Dim tbl As New Table
   Dim cat As New ADOX.Catalog

'Open the catalog.
   ' Open the Catalog.
   cat.ActiveConnection
= "Provider=Microsoft.Jet.Oledb.4.0;Data
Source=D:\NorthWind.mdb;"

   tbl.Name = "MyTable"
   tbl.Columns.Append "Column1", adInteger
   tbl.Columns.Append "Column2", adInteger
   tbl.Columns.Append "Column3", adVarWChar, 50

   cat.Tables.Append tbl
tbl.Columns(0).Properties("Description") = "Notice this is
the First columns Description"
tbl.Columns(1).Properties("Description") = "Notice this is
the second columns Description"
tbl.Columns(2).Properties("Description") = "Notice this is
the Third columns Description"
End Sub

Quote:
>-----Original Message-----
>how to programmatically write to the "Description" column
in an Access
>design-view of a table . . . ?

>.



Sun, 11 Jan 2004 04:41:41 GMT
 write to "Description" col in Access
This code to add a description to a table and field to an access.mdb

Sub CallPropertySet()
    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Dim blnReturn As Boolean

    ' Return reference to current database.
    Set dbs = CurrentDb

    ' Return reference to CustomersTest table.
    Set tdf = dbs.TableDefs!CustomersTest
    ' Return reference to CompanyName field.
    Set fld = tdf!ContactName

    ' Call SetAccessProperty function for the table.
    blnReturn = SetAccessProperty(tdf, "Description", dbText, "This is a
table Description")

    ' Call SetAccessProperty function for the field.
    blnReturn = SetAccessProperty(fld, "Description", dbText, "This is a
field Description")

    ' Evaluate return value.
    If blnReturn = True Then
        Debug.Print "Property set successfully."
    Else
        Debug.Print "Property not set successfully."
    End If
End Sub

Function SetAccessProperty(obj As Object, strName As String, _
        intType As Integer, varSetting As Variant) As Boolean

    Dim prp As Property
    Const conPropNotFound As Integer = 3270

    On Error GoTo ErrorSetAccessProperty
    ' Explicitly refer to Properties collection.
    obj.Properties(strName) = varSetting
    obj.Properties.Refresh
    SetAccessProperty = True

ExitSetAccessProperty:
    Exit Function
ErrorSetAccessProperty:
    If Err = conPropNotFound Then
        ' Create property, denote type, and set initial value.
        Set prp = obj.CreateProperty(strName, intType, varSetting)
        ' Append Property object to Properties collection.
        obj.Properties.Append prp
        obj.Properties.Refresh
        SetAccessProperty = True
        Resume ExitSetAccessProperty
    Else
        MsgBox Err & ": " & vbCrLf & Err.Description
        SetAccessProperty = False
        Resume ExitSetAccessProperty
    End If
End Function

HTH- BTW if anyone has the equivalent for SQL Server 2000, I would
appreciate it.

Adam
--------------------------------------------------------
Check out these HOT UTILITIES FOR ACCESS AND VB DEVELOPERS....
www.ssw.com.au
* SSW Data PRO  - Version Control for your data.mdb
* SSW Data Renovator  - Compare the differences between two data.mdb's
* SSW Upsize PRO! - Don't UPSIZE to SQL Server without it
* SSW SQL Script Wizard - A utility to run .sql files
* SSW Performance PRO! - Find out what is slow in your Access App
--------------------------------------------------------



Quote:
> how to programmatically write to the "Description" column in an Access
> design-view of a table . . . ?



Sun, 11 Jan 2004 09:29:53 GMT
 write to "Description" col in Access
Use ADOX to set the value... The example below adds a
table to the Northwind database and sets the Description
of the fields.

Create a new VB PRoject

Add the following references to the project

Microsoft ActiveX Data Objects 2.6 Library
Microsoft ADO Ext. 2.6 for DDL and Security

Copy code into form

------------------Code Begins ------------------------
Private Sub Form_Load()

   Dim tbl As New Table
   Dim cat As New ADOX.Catalog

'Open the catalog.
   ' Open the Catalog.
   cat.ActiveConnection
= "Provider=Microsoft.Jet.Oledb.4.0;Data
Source=D:\NorthWind.mdb;"

   tbl.Name = "MyTable"
   tbl.Columns.Append "Column1", adInteger
   tbl.Columns.Append "Column2", adInteger
   tbl.Columns.Append "Column3", adVarWChar, 50

   cat.Tables.Append tbl
tbl.Columns(0).Properties("Description") = "Notice this is
the First columns Description"
tbl.Columns(1).Properties("Description") = "Notice this is
the second columns Description"
tbl.Columns(2).Properties("Description") = "Notice this is
the Third columns Description"
End Sub

Quote:


>Subject: write to "Description" col in Access
>Date: Tue, 24 Jul 2001 10:01:28 -0700
>Lines: 4
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200

>Newsgroups: microsoft.public.data.ado
>NNTP-Posting-Host: adsl-64-167-132-46.dsl.snfc21.pacbell.net 64.167.132.46
>Path: cppssbbsa01.microsoft.com!tkmsftngp01!tkmsftngp04
>Xref: cppssbbsa01.microsoft.com microsoft.public.data.ado:33093
>X-Tomcat-NG: microsoft.public.data.ado

>how to programmatically write to the "Description" column in an Access
>design-view of a table . . . ?



Sun, 11 Jan 2004 20:55:15 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. max of ("...","...","..")

2. Extracting "Column Description" from schema

3. Error Message for Description "Pull"

4. Best data type for "Description" field

5. SQLDMO has serverrole "description"

6. Querying Column "Description"

7. column "description"?

8. select * from syscolumns has no "description"-field

9. Field.Properties("Description")

10. "@ row(), col() say..." acting like "??" after shelling to another application


 
Powered by phpBB® Forum Software