Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Field propert by code (Access 2000)

    I need to create a property of a table thourgh a code. I cannot create the property "ShortDate" in the field Format
    of the table "Orders" . The function i have adds the Defau values Date and PaymentID, but does not add the property ShortDate in the field Format
    of the table orders. I define this propert as prp. Can somebody tell my where my error in the function is ?

    The function is the following

    Private Function AddOn()
    Dim dbs As DAO.Database
    Set dbs = CurrentDb
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Dim fld1 As DAO.Field
    Dim prp As DAO.Property
    Set tdf = dbs.TableDefs("Orders")
    ' set additional field properties for the field orderdate
    Set fld = tdf.Fields("OrderDate")
    fld.Properties("DefaultValue") = "=Date()"
    Set prp = fld.CreateProperty("Format", dbText, "Short Date")
    ' set additional property the field PaymentID to be 0
    Set fld1 = tdf.Fields("PaymentID")
    fld1.Properties("DefaultValue") = 0
    dbs.Close
    Set prp = Nothing
    Set fld = Nothing
    Set fld1 = Nothing
    Set tdf = Nothing
    Set dbs = Nothing
    End Function

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

    Re: Field propert by code (Access 2000)

    After creating a property, you must append it to the Properties collection, otherwise it will be ignored:

    Set prp = fld.CreateProperty("Format", dbText, "Short Date")
    fld.Properties.Append prp

Posting Permissions

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