Results 1 to 7 of 7
  1. #1
    Jrw76 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2013
    Posts
    38

    Dmax

    I have a form with a textbox(Text202) bound to a field(PlateNo) in a table. I would like to use Dmax to find the largest value in that field and add 1 to it, and reapply this to the textbox in the form. I would like to have this behind a button. I can't use AutoNumber in this situation, or I would and I'm unsure of how Dmax works. Any help would be great.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    Perhaps you could use an expression in the Default Value property of Textbox202. Maybe something like:
    =DMax("[PlateNo]","[YourTableName]")
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Should that be:

    =DMax("[PlateNo]","[YourTableName]") + 1

    Be careful, until this record is committed table, another user could generate the same value - if this is a multi-user db.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Is this going to be used as a single-user app or is it being used in a multi-user environment? It makes a big difference, as June7 suggested, when deciding where to place the code.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Jrw76 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2013
    Posts
    38
    Never Mind...Just figured it out.

  6. #6
    Jrw76 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2013
    Posts
    38
    Well, Only one user at a time for this form. So it should not happen.

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    Quote Originally Posted by June7 View Post
    Should that be:

    =DMax("[PlateNo]","[YourTableName]") + 1

    Be careful, until this record is committed table, another user could generate the same value - if this is a multi-user db.
    Yes it should be. Thank you June
    June and Linq make a good point about where the code is used.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. dmax value
    By sdel_nevo in forum Programming
    Replies: 2
    Last Post: 09-12-2013, 04:14 AM
  2. DMAX in VBA
    By Meanfish in forum Access
    Replies: 1
    Last Post: 11-03-2012, 11:06 AM
  3. Replies: 6
    Last Post: 07-24-2012, 03:02 PM
  4. How to use DMAX
    By tomneedshelp in forum Access
    Replies: 2
    Last Post: 03-01-2012, 07:22 AM
  5. Using Nz and Dmax
    By timmy in forum Programming
    Replies: 5
    Last Post: 07-04-2011, 06:42 AM

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