Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Emerald Beach, New South Wales, Australia
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Write table Field Property 'Description' with code (access 97)

    I'm trying to write a description to a table field via code. If there is a description in the table I can successfully change the description but if there is no description I'm not getting access to the description property.

    I'm assuming that I have to append/create the property but can not seem to get it working.

    Can anyone give me a sample block of code or a pointer as to the correct method?

    Thanks
    Stewart

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Write table Field Property 'Description' with

    Here is sample code to do this, A2K but since uses DAO should work in ACC 97:
    <pre>Sub AddFldDescrip(strTblName As String, strFldName As String, strFldDescrip As String)
    On Error GoTo Err_Handler

    Dim db As DAO.Database
    Dim tbl As DAO.TableDef
    Dim fld As DAO.Field
    Dim prop As DAO.Property
    Dim strMsg As String

    Set db = CurrentDb
    Set tbl = db.TableDefs(strTblName)
    Set fld = tbl.Fields(strFldName)

    fld.Properties("Description") = strFldDescrip

    Exit_Sub:
    Set db = Nothing
    Set tbl = Nothing
    Set fld = Nothing
    Set prop = Nothing
    Exit Sub
    Err_Handler:
    If Err = 3270 Then 'Property not found
    Set prop = fld.CreateProperty("Description", dbText, strFldDescrip)
    fld.Properties.Append prop
    Resume
    Else
    strMsg = "Error No " & Err.Number & ": " & Err.DESCRIPTION
    Beep
    MsgBox strMsg, vbExclamation, "FIELD DESCRIPTION ERROR MESSAGE"
    Resume Exit_Sub
    End If

    End Sub
    </pre>

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •