Connecting Tech Pros Worldwide Help | Site Map

Help with this auto numbering field

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 11th, 2008, 03:05 PM
rhaazy
Guest
 
Posts: n/a
Default Help with this auto numbering field

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, 04:45 PM
Salad
Guest
 
Posts: n/a
Default 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, 12:15 AM
Wayne Gillespie
Guest
 
Posts: n/a
Default 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, 12:05 PM
rhaazy
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.