Results 1 to 3 of 3
  1. #1
    marco is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    1

    Select MAX ( ) +1

    Hi everyone,
    I hope I post in the right place!
    I have a problem with a custom autonumber field.


    For most tables of my db I use 'select max(table) +1' and everything is fine. But I have some tables in which my Pk are something like 'ART00031'.
    In this case my query gives me an error.
    What should I change?

    Thanks in advance,

  2. #2
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    It seems you've discovered why Access uses "Autonumber" as a table key, and not "Autoletter".

    Max() is a mathematical function and is meant to apply to numbers, not letters or text strings.

    If you're going to change anything (and you want to continue using Max()+1 for a key generator), you should change your keys to numbers.

    Cheers,

  3. #3
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    If you insist on keeping the text, one way around it would be to make your primary key a concatenated, calculated field. I take it the ART is a category. Create a separate column for category, and one for the number. the number field would be your usual Max()+1. then your true primary key field would be pk:Category&Number

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

Similar Threads

  1. Use one subform as a select list
    By larryb43 in forum Forms
    Replies: 0
    Last Post: 02-27-2010, 03:08 PM
  2. Select value from a list box
    By Hidenite in forum Queries
    Replies: 8
    Last Post: 01-29-2010, 11:31 AM
  3. Field Select
    By RaptureReady in forum Forms
    Replies: 1
    Last Post: 01-28-2010, 08:29 PM
  4. SELECT returns more than one row
    By 83dons in forum Queries
    Replies: 1
    Last Post: 01-13-2010, 11:28 AM
  5. SELECT FUNCTION help please
    By scott munkirs in forum Queries
    Replies: 0
    Last Post: 10-17-2006, 07:44 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