Results 1 to 5 of 5
  1. #1
    vermette09 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2014
    Posts
    19

    Trying to Set From Field Default Value as Dmax()+1

    I have a form created for entering new purchase orders. I want the form to default the value to the max purchase order number + 1 to represent the next available number. The problem is, because of the formatting of our purchase order numbers (yy-####, ex. 14-0123) it can't add "+1" to the value because it has to be a text field. Currently I have the default value set to DMax("Purchase_Order_Number","xtblPurchaseOrders") and it defaults to the most recent PO, but I was wondering if there was a way I could get it to add 1 to that number even though it is a text field. I can't seem to find anything with the same scenario as mine.

    Your help is appreciated,


    Josh

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Try,

    MID(DMax("Purchase_Order_Number","xtblPurchaseOrde rs"), 1, 3) & FORMAT(CLNG(MID(DMax("Purchase_Order_Number","xtbl PurchaseOrders"), 4)) + 1, "0000")

  3. #3
    vermette09 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2014
    Posts
    19
    That works! I didn't notice the space between xtblPurchaseOrders on the second part, my bad. Thank you very much!

    Best,
    Josh
    Last edited by vermette09; 05-08-2014 at 11:42 AM. Reason: I was wrong, it was right!

  4. #4
    vermette09 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2014
    Posts
    19
    Post Removed...

  5. #5
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    The "0000" is part of the "FORMAT" to convert the number back to text field with leading zero.

    http://www.techonthenet.com/access/f...ing/format.php

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Default value of a field
    By data808 in forum Forms
    Replies: 4
    Last Post: 01-10-2014, 08:13 PM
  2. Default value in field based on value in other field
    By smith.jr in forum Database Design
    Replies: 2
    Last Post: 01-08-2014, 12:29 PM
  3. DMax in form's Default Value property
    By RonL in forum Forms
    Replies: 5
    Last Post: 01-14-2013, 03:35 PM
  4. Default Value from Another Field
    By ineedaccesshelp in forum Access
    Replies: 5
    Last Post: 11-28-2012, 12:37 PM
  5. Replies: 6
    Last Post: 07-24-2012, 03:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums