Results 1 to 6 of 6
  1. #1
    ToolJob is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    5

    Custom ID field issue

    I added a index field whose values look like this:

    12-001
    12-002
    12-003
    etc

    When I use the following command to get the last ID in the table:

    lastID = DLast("NCR_ID", "NCR_RECORDS")

    I am expecting 12-029

    but I am getting "!29" instead????



    Not sure why? I am figuring it is a data type issue, but how do I display an auto-number field (like I am using) as a valid data type so I can get the expected format of 12-xxx??

    Thanks


    TJ

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Do NOT use DLast. Databases do not store data in sequential order necessarily.

    Google Dmax and Dmax+1

    There's a lot of discussion of CustomId's on the net.
    Here is a recent discussion that may help put some context of your request/issue.
    http://www.access-programmers.co.uk/...d.php?t=244894

  3. #3
    ToolJob is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    5
    Quote Originally Posted by orange View Post
    Do NOT use DLast. Databases do not store data in sequential order necessarily.

    Google Dmax and Dmax+1

    There's a lot of discussion of CustomId's on the net.
    Here is a recent discussion that may help put some context of your request/issue.
    www.access-programmers.co.uk/forums/showthread.php?t=244894
    Orange, thanks I did change my code to use the Dmax. The issue I am still having is reading the custom ID.

    Like I said the last inserted record is 12-029 - when I popup a message box with the value I am getting - "!29"

    I am not sure why?

    Thanks in advance

    TJ

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Me either. Because of your format you are dealing with a text field.
    Where is the autonumber? What processing are you doing with the data?
    Why do you have this code 12-029?

  5. #5
    ToolJob is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    5
    Quote Originally Posted by orange View Post
    Me either. Because of your format you are dealing with a text field.
    Where is the autonumber? What processing are you doing with the data?
    Why do you have this code 12-029?

    I wanted to use a custom ID...I wonder if there is a way I can change the auto-number field to 1,2,3,4,5...etc...and than have another column to concatenate the ID field with my customID

    so I would take the ID columne value "1"

    and concatenate that with "12-XXX" to make "12-001"?

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

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

Similar Threads

  1. Display custom error if field is null or zero
    By steve87bg in forum Access
    Replies: 1
    Last Post: 01-14-2013, 02:33 AM
  2. Custom Query field
    By yeleek in forum Queries
    Replies: 3
    Last Post: 06-07-2012, 07:58 AM
  3. Design Issue: Custom Property?
    By Stan Denman in forum Database Design
    Replies: 2
    Last Post: 03-30-2012, 11:11 AM
  4. Setting Custom Field Format Property Problem
    By Weelmaa in forum Programming
    Replies: 2
    Last Post: 02-25-2012, 05:33 AM
  5. Field Issue
    By recon2011 in forum Forms
    Replies: 14
    Last Post: 08-12-2011, 12:16 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