Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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

    <pre>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
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

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

    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):
    <code>
    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</code>

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    Perfect!

    Thank you

Posting Permissions

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