Connecting Tech Pros Worldwide Help | Site Map

Help with this auto numbering field

rhaazy
Guest
 
Posts: n/a
#1: Mar 11 '08
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.
Salad
Guest
 
Posts: n/a
#2: Mar 11 '08

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
Wayne Gillespie
Guest
 
Posts: n/a
#3: Mar 12 '08

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
rhaazy
Guest
 
Posts: n/a
#4: Mar 12 '08

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