# Thread: Simple record counter in report

1. Registered User
Join Date
Jul 2003
Posts
13

## Unanswered: Simple record counter in report

HELP! HELP! HELP!

I've made a report that makes selections based on criteria I can give.
The result however must contain a articlenumber combined with a counting number.

Like so: AXO940001001-005426. The last 6 digits is the counting number, but HOW TO GET THIS DONE?

The (starting) counternumber must also be adjustable so different series can be made.

Example:
I give in a number to start counting at: 005243
I have a 100 records displayed in the report.
The new numbers should be like this:
AXO9400010001-005243
AXO9400010001-005244
AXO9400010001-005245
etc.

2. Village Idiot
Join Date
Jul 2003
Location
Michigan
Posts
1,941
There's multiple ways to do this. Here's a simple one...

Dim strID as string, intCntr as integer, strCntr as string * 6
Dim strArtNum as string, intPos as integer
strCntr = String(6,"0")
'get your last article & counter number
strArtNum = ArticleNumber
'extract the counter number
intCntr =Cint(right(strArtNum,6)
intCntr=intCntr+1
'how many of the 6 digits are we using?
intPos= len(Cstr(intCntr))
strCntr=left(strcntr,6-intPos) & cstr(intcntr)
'find the position of the '-'
intPos = Instr(1, strArtNum, "-")
'replace the counting number
strArtNum = left(strArtNum,intPos) & strCntr

3. Registered User
Join Date
Jul 2003
Posts
13
I really appreciate your answer, but I'm not really a VB wizzkid!

Where should I put this code you gave me?

Tnx !

4. Village Idiot
Join Date
Jul 2003
Location
Michigan
Posts
1,941

Are you storing the combination of Article Number and counter anywhere
in your DB? Or are you making up the counter numbers on the fly?

5. Registered User
Join Date
Jul 2003
Posts
13
I'd rather not store the counter number, because it might make it even more difficult to handle. The counter numbers are preferably based on the input of a 6 digit startnumber.

6. Registered User
Join Date
Jul 2003
Posts
13
I'd really appreciate it if you could help me!

My reports are have just gaind a priority status up to nr1.

7. Village Idiot
Join Date
Jul 2003
Location
Michigan
Posts
1,941
Can you attach what you have so far? I'll make changes and send it back.

8. Registered User
Join Date
Jul 2003
Posts
13
Here it is! Hope you can fix it.

9. Village Idiot
Join Date
Jul 2003
Location
Michigan
Posts
1,941
This should do it. I changed the last text box on the report to show the
value you asked for. When you open the report, you are asked for a starting counter number.

Open the report in design view, and click on the 'Code' button on the
toolbar. That will take you into the module for the report. There's not
much code involved, but I put plenty of comments in to explain what's going on.

Hope that's what you need!
Mark

10. Registered User
Join Date
Jul 2003
Posts
13
YESSSSSSSS...

IT WORKS !!!

Thank you very much for helping. I really have to study more VB.

Best regards,

Michael Beck
maabeck@hotmail.com

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•