Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default value (Access 2000)

    I want to change the default value of the field Quantity from 1 to 0 with the following command:
    CurrentDb.TableDefs("order details").Fields("Quantity").Default = 0

    but i receive the message " method or data member not found "

    Also the same filed has a Validation Rule > 0. How can i delete this requirement?

    How can i correct my command?

    Of course i could do it by opening the database in design view,nothing simpler than that, but i need to send this command
    to a person in another town, who has no direct access to the table

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

    Re: Default value (Access 2000)

    Perhaps not unexpectedly, the property is named DefaultValue, not Default.
    The ValidationRule property is a string. To remove a validation rule, set it to "".

    Note: it is advisable to use object variables when working with TableDefs, Fields, etc:

    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field

    Set dbs = CurrentDb
    Set tdf = dbs.TableDefs("Order Details")
    Set fld = tdf.Fields("Quantity")

    With fld
    .DefaultValue = 0
    .ValidationRule = ""
    .ValidationText = ""
    End With

    ...

    Set fld = Nothing
    Set tdf = Nothing
    Set dbs = Nothing

    It looks more complicated, but it makes debugging a lot easier - you'll know far more specifically where an error occurs.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Default value (Access 2000)

    Superb !! I liked your answer very much

    I wish you a nice day

Posting Permissions

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