Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002
    Location
    Hartford, CT
    Posts
    106

    Question Unanswered: Add a new record from a form

    I have an add button on a form that is linked to a table in the same database. How can I assign an incremental value to a field as soon as the user hits add a new record button? The login is, get the heights value in that field and add 1 to it and paste it in the text box.

    Please help.

    Thanks
    Mo

  2. #2
    Join Date
    Nov 2002
    Location
    Hillsboro, OR, USA
    Posts
    59

    Re: Add a new record from a form

    Why not use an autonumber data type?

    If you have a good reason not to, some variation of this should work:

    Code:
    ...
    
    me.YourField = (DMax("[YourField]","YourTable")+1)
    
    ...
    Be careful where you use DMax and the other domain aggregate functions. They can really slow things down but are fine for a button that is clicked once in a while.

    Brian

Posting Permissions

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