Connecting Tech Pros Worldwide Help | Site Map

Help with this auto numbering field

  #1  
Old March 11th, 2008, 04:05 PM
rhaazy
Guest
 
Posts: n/a
I want to know in Access if it is possible to have a table with an
auto number that behaves in the following fashion.

Group ID
A 1
A 2
A 3
A 4
B 1
B 2
B 3
C 1
C 2
......

If this can be done please explain where to look to implement this.
Thanks.
  #2  
Old March 11th, 2008, 05:45 PM
Salad
Guest
 
Posts: n/a

re: Help with this auto numbering field


rhaazy wrote:
Quote:
I want to know in Access if it is possible to have a table with an
auto number that behaves in the following fashion.
>
Group ID
A 1
A 2
A 3
A 4
B 1
B 2
B 3
C 1
C 2
.....
>
If this can be done please explain where to look to implement this.
Thanks.
Autonumber? No. Number/LongInt? Yes.

You could get a number like
If me.NewRecord Then _
Me.NewID = DMax("ID","TableName","Group = '" & Me.Group & "'") + 1

You'd want to do this when the record is saved.

Sarah
http://www.youtube.com/watch?v=A_jCNchJSyI
  #3  
Old March 12th, 2008, 01:15 AM
Wayne Gillespie
Guest
 
Posts: n/a

re: Help with this auto numbering field


On Tue, 11 Mar 2008 09:40:42 -0700, Salad <oil@vinegar.comwrote:
Quote:
>rhaazy wrote:
Quote:
>I want to know in Access if it is possible to have a table with an
>auto number that behaves in the following fashion.
>>
>Group ID
>A 1
>A 2
>A 3
>A 4
>B 1
>B 2
>B 3
>C 1
>C 2
>.....
>>
>If this can be done please explain where to look to implement this.
>Thanks.
>
>Autonumber? No. Number/LongInt? Yes.
>
>You could get a number like
If me.NewRecord Then _
Me.NewID = DMax("ID","TableName","Group = '" & Me.Group & "'") + 1
>
>You'd want to do this when the record is saved.
>
>Sarah
>http://www.youtube.com/watch?v=A_jCNchJSyI

You need to wrap the DMax in a Nz function, otherwise it will error if it is the
first record for a particular group.

Me.NewID = Nz(DMax("ID","TableName","Group = '" & Me.Group & "'")) + 1


Wayne Gillespie
Gosford NSW Australia
  #4  
Old March 12th, 2008, 01:05 PM
rhaazy
Guest
 
Posts: n/a

re: Help with this auto numbering field


On Mar 11, 8:05*pm, Wayne Gillespie <best...@NOhotmailSPAM.com.au>
wrote:
Quote:
On Tue, 11 Mar 2008 09:40:42 -0700, Salad <o...@vinegar.comwrote:
Quote:
rhaazy wrote:
Quote:
I want to know in Access if it is possible to have a table with an
auto number that behaves in the following fashion.
>
Quote:
Quote:
Group * * * * ID
A * * * * * * * 1
A * * * * * * * 2
A * * * * * * * 3
A * * * * * * * 4
B * * * * * * * 1
B * * * * * * * 2
B * * * * * * * 3
C * * * * * * * 1
C * * * * * * * 2
.....
>
Quote:
Quote:
If this can be done please explain where to look to implement this.
Thanks.
>
Quote:
Autonumber? *No. *Number/LongInt? Yes.
>
Quote:
You could get a number like
* If me.NewRecord Then _
* * Me.NewID = DMax("ID","TableName","Group = '" & Me.Group & "'") + 1
>
Quote:
You'd want to do this when the record is saved.
>>
You need to wrap the DMax in a Nz function, otherwise it will error if it is the
first record for a particular group.
>
Me.NewID = Nz(DMax("ID","TableName","Group = '" & Me.Group & "'")) + 1
>
Wayne Gillespie
Gosford NSW Australia- Hide quoted text -
>
- Show quoted text -
thanks everyone
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
autonumbering of a field with several categories sonny minor answers 3 May 30th, 2009 08:19 AM
Updating the SQL key value bill answers 33 April 4th, 2007 02:55 PM
Order data items in a list or grid Eric Eckberg answers 2 November 20th, 2005 09:31 AM
Automatically get data in field when picking something in other field jballard@acecwi.com answers 7 November 13th, 2005 06:40 AM