Results 1 to 3 of 3
  1. #1
    FRAZ is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    12

    Incrementing number in a query

    I need to be able to asign a record number to a query for example if I do a make table query, witch adds 10 records how could I assign the number 1 through 10 to a field in that table.



    Thanks

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I usually use DAO to do things like that. Since you are using a MAKE TABLE, maybe you can have a Boolean with default value -1. After the MAKE TABLE run's you can go back over it with the DAO and increment an integer variable using a loop. If multiple users, you may need a column to store an unique session ID to verify the DAO is retrieving the correct records.

    maybe someone knows a better way to increment or a property setting at the table level....

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I have seen several methods, but don't remember exactly how to create the query and I don't have all of reference sites available.

    If you sort the data on MyField (Ascending) you could use something like...
    Code:
    Counter:(SELECT COUNT(*) FROM MyTable AS T WHERE T.MyField <= MyTable.MyField)
    Also, look at Roger's Access Library site:
    NumberedQuery.mdb (beginner)
    http://www.rogersaccesslibrary.com/forum/topic309.html

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

Similar Threads

  1. Replies: 5
    Last Post: 04-16-2013, 07:24 PM
  2. Help With Incrementing field number
    By Neil2p in forum Programming
    Replies: 1
    Last Post: 03-18-2013, 08:17 AM
  3. Replies: 1
    Last Post: 11-30-2011, 11:02 AM
  4. Replies: 1
    Last Post: 07-27-2011, 09:19 AM
  5. Custom & Auto Incrementing Job Number
    By mastromb in forum Programming
    Replies: 1
    Last Post: 01-05-2010, 02:58 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