Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Location
    Warren, PA
    Posts
    52

    Exclamation Unanswered: Set a fields format property using VBA

    I need to update a fields property in the table, lets call the table products and the field prodnum. The prodnum field need to be a long integer formatted 00000 (five zeros).

    CurrentDb.Execute "ALTER TABLE products Add COLUMN prodnum long"
    Works fine creates the field I need

    I have event tryied this with no luck.
    Set DB = CurrentDb()
    Set Newtbl = DB.CreateTableDef(products)
    Set newfld = Newtbl.CreateField("prodnum", dbLong)
    Set fldprop = newfld.CreateProperty("Format", dbLong, “00000”)
    newfld.Properties.Append fldprop

    I can’t seem to get the formatting to work. Have at it see what you can come up with. Go ahead and change what you need as long as it adds the field to the table and sets it as a Long Integer formatted to 00000. Thanks
    bhummel

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Do you need leading zeros? You can't store leading zeros in a table unless you use text.

    Try applying the format to a textbox on a form instead.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Nov 2003
    Location
    Warren, PA
    Posts
    52
    Quote Originally Posted by Teddy
    Do you need leading zeros? You can't store leading zeros in a table unless you use text.

    Try applying the format to a textbox on a form instead.
    Not to store them but see them the data is not viewed from a form
    bhummel

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    How is the data viewed?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Nov 2003
    Location
    Warren, PA
    Posts
    52
    Quote Originally Posted by Teddy
    How is the data viewed?
    From the table

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Then you have to use text. That's it.

    The question them becomes, why is it ABSOLUTELY NECESSARY to have the data viewed a certain way in the table itself, when it would be incredibly simple to reformat it by sucking it into a form?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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