Renumber

hiền muội

small girl in a big world
Local time
Tomorrow, 06:23
Joined
Jun 11, 2009
Messages
23
I have a table :


ID___ Code _____Numchar
1_____56_______ 1
2_____55_______ 2
3_____93_____ 3
4_____140_____ 4
5_____144_____ 5
6_____176_____ 6
7_____206_____ 7
8_____230_____ 8
9_____259_____ 9
10_____267_____10
11_____290_____11
12_____300_____12
13_____306_____13
14_____321_____14
15_____327_____15
16_____431_____16
17_____451_____17
18_____478_____18
19_____488_____19
20_____505_____20
21_____531_____21
22_____545_____22
23_____588_____23
24_____590_____24
25_____621_____25
26_____628_____26
27_____659_____27
28_____692_____28
29_____703_____29
30_____718_____30
31_____722_____31
32_____788_____32
33_____798_____33
34_____887_____34
38_____798_____35
39_____887_____36

and I make a query with Group column like below:

ID___ Code _____Numchar_____Group
1_____56_______ 1_________1
2_____55_______ 2_________2
3_____93_____ 3_________3
4_____140_____ 4_________4
5_____144_____ 5_________5
6_____176_____ 6_________1
7_____206_____ 7_________2
8_____230_____ 8_________3
9_____259_____ 9_________4
10_____267_____10_________5
11_____290_____11_________1
12_____300_____12_________2
13_____306_____13_________3
14_____321_____14_________4
15_____327_____15_________5
16_____431_____16_________1
17_____451_____17_________2
18_____478_____18_________3
19_____488_____19_________4
20_____505_____20_________5
21_____531_____21_________1
22_____545_____22_________2
23_____588_____23_________3
24_____590_____24_________4
25_____621_____25_________5
26_____628_____26_________1
27_____659_____27_________2
28_____692_____28_________3
29_____703_____29_________4
30_____718_____30_________5
31_____722_____31_________1
32_____788_____32_________2
33_____798_____33_________3
34_____887_____34_________4
38_____798_____35_________5
39_____887_____36_________1

I searched lots of threads but nothing can help my problem.

I appreciate your help.
Thank you very much
 
You are going to need to loop through your records and apply numbering 1 to 5 on a rolling basis as you progress through your records.

Have a look at the attached sample, particularly the code in the On Click event of the button.
 

Attachments

There is a much easier alternative than a loop.

Group: IIF((Numchar MOD 5)=0,5,(NumChar MOD 5))
 
There is a much easier alternative than a loop.

Group: IIF((Numchar MOD 5)=0,5,(NumChar MOD 5))

Much more elegant, and far simpler :D

For proof of concept check the After Update event on the field named Code.
 

Attachments

Users who are viewing this thread

Back
Top Bottom