• Help With fld.Properties. Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Help With fld.Properties. Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Author
    Topic
    #446911

    Need the correct syntax to set the Format property to “>” for BE, table and field

    strBE=F:AppsAccess2kClerkTlaClerk.md
    strTbl=tbl_DL_Breed
    strFld=strBreedCode

    Thanks, John

    Public Sub SetFormat(strBE As String, strTbl As String, strFld As String)
        
        Dim dbs As DAO.Database
        Dim tdf As DAO.TableDef
        Dim fld As DAO.Field
    
        On Error GoTo ErrHandler
    
        Set dbs = DBEngine.OpenDatabase(strBE)
        Set tdf = dbs.TableDefs(strTbl)
        Set fld = tdf.Fields(strFld)
        
        ??? fld.Properties.Append "Format", ">"
       
    ExitHandler:
        On Error Resume Next
        Set fld = Nothing
        Set tdf = Nothing
        dbs.Close
        Set dbs = Nothing
        Exit Sub
    
    ErrHandler:
        MsgBox Err & ": " & Err.Description, vbExclamation
        Resume ExitHandler
    End Sub
    
    Viewing 0 reply threads
    Author
    Replies
    • #1087896

      You must create the property if it doesn’t exist yet (fields start out without a Format property). You can do this in the error handler if error 3270 occurs (property not found):

      Public Sub SetFormat(strBE As String, strTbl As String, strFld As String)
      Dim dbs As DAO.Database
      Dim tdf As DAO.TableDef
      Dim fld As DAO.Field

      On Error GoTo ErrHandler

      Set dbs = DBEngine.OpenDatabase(strBE)
      Set tdf = dbs.TableDefs(strTbl)
      Set fld = tdf.Fields(strFld)

      fld.Properties("Format") = ">"

      ExitHandler:
      On Error Resume Next
      Set fld = Nothing
      Set tdf = Nothing
      dbs.Close
      Set dbs = Nothing
      Exit Sub

      ErrHandler:
      If Err = 3270 Then
      fld.Properties.Append fld.CreateProperty("Format", dbText, ">")
      Resume Next
      Else
      MsgBox Err & ": " & Err.Description, vbExclamation
      Resume ExitHandler
      End If
      End Sub

    Viewing 0 reply threads
    Reply To: Help With fld.Properties. Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

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

    Your information: