Results 1 to 11 of 11
  1. #1
    Mando is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    5

    Question I want my asset numbers with letters to auto-populate as i enter a new asset


    my asset numbers look like this MIT000001DT, MIT000002DT, etc is there a way to auto populate my asset number without having o enter it. I was thinking it would look like this $$$000001$$ + 1= (new asset number)? any suggestions?

  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,543
    Try:
    ="MIT" & Mid(DMax("[AssetNum]","[tblAssets]"),4,6) & "DT"
    Change AssetNum to the name of the field that has the asset numbers and change tblAssets to the name of your table.
    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
    Mando is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    5
    I tried entering in the Table Design of the field and it would not accept this expression. I don't think that I set it in the form, but is there a different place to input the formula?

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if you're storing the asset number as a string and not a number (if you're storing it as a number you can make the display format be anything you want)

    AssetNum = "MIT" & right("000000" & (Mid(DMax("[AssetNum]","[tblAssets]"),4,6)+ 1),6) & "DT"

    I think bob's will give you just the most recent assetnumber (assuming it's stored as a number)

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    If you're using a bound form you'd use the code when you have enough data to confirm that it's a valid new record (i.e. all the required fields have been entered)

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    The expression I posted will return the next number to be used from a field in which the asset number is stored with both the prefix and suffix that the OP posted.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Really? how is it incrementing from the maximum record?

    let's say his current maximum record is MIT000010DT wouldn't the expression:

    ="MIT" & Mid(DMax("[AssetNum]","[tblAssets]"),4,6) & "DT"

    return
    dmax("[AssetNum]", "tblAssets") would return MIT000010DT so the expression would become

    "MIT" & mid("MIT000010DT", 4,6) & "DT"

    which is

    "MIT" & "000010" & "DT"?

    I guess I am not catching how this expression alone would increment.

  8. #8
    Mando is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    5
    Where do I enter this expression the table property sheet wont accept it and I put it in the form and it didn't do anything. I will keep trrying thanks you guys. it has been helpful

  9. #9
    Mando is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    5
    the expression can not be calculated

  10. #10
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You don't enter the formula on the table. If you are using a BOUND form (you are using either a table or a query as the record source for your form) you would have something like

    Code:
    if isnull(AssetNum)
       AssetNum = <put your formula here>
    endif
    so if assetnum is blank (not filled in) your code will populate it, otherwise it will leave the assetnum alone, if you are using a bound form I would suggest you set the LOCKED property of that field to TRUE so that your users won't accidentally change the value.

  11. #11
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    Quote Originally Posted by rpeare View Post
    Really? how is it incrementing from the maximum record?

    let's say his current maximum record is MIT000010DT wouldn't the expression:

    ="MIT" & Mid(DMax("[AssetNum]","[tblAssets]"),4,6) & "DT"

    return
    dmax("[AssetNum]", "tblAssets") would return MIT000010DT so the expression would become

    "MIT" & mid("MIT000010DT", 4,6) & "DT"

    which is

    "MIT" & "000010" & "DT"?

    I guess I am not catching how this expression alone would increment.
    My apologies. You are of course quite right in stating that it will not increment. Between testing and posting I've managed to loose the +1 in the expression. Sorry
    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. Asset Tracking
    By mm26 in forum Database Design
    Replies: 9
    Last Post: 02-24-2014, 02:45 AM
  2. Location of asset and latest record for asset
    By duramax in forum Queries
    Replies: 11
    Last Post: 05-14-2013, 04:31 PM
  3. Asset Management Web Database
    By gemadan96 in forum SharePoint
    Replies: 2
    Last Post: 05-01-2013, 02:36 PM
  4. Asset Tracking Database
    By wgroenewald in forum Access
    Replies: 3
    Last Post: 02-13-2012, 08:26 PM
  5. Purchase price of asset
    By Ron.Sul in forum Access
    Replies: 4
    Last Post: 09-17-2010, 11:28 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