• Write table Field Property ‘Description’ with code (access 97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Write table Field Property ‘Description’ with code (access 97)

    Author
    Topic
    #371977

    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

    Viewing 0 reply threads
    Author
    Replies
    • #593033

      Here is sample code to do this, A2K but since uses DAO should work in ACC 97:

      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
      

      HTH

    Viewing 0 reply threads
    Reply To: Write table Field Property ‘Description’ with code (access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: