Home

Macros and Programming

 

CardboxForumsMacros and Programming > "Incremental Numbering"

Incremental Numbering

Looking to insert fields to increment by 1 at each record

Current user: [none]
Register / Log In · Help

Posted By Post

Woody123

5-Mar-2012 17:00

Hi i am looking to give each record a reference number eg ABC001/A then ABC002/A for the next record.

I have this already:
Do
EditRecord
n = 1
ref1 = n + 1
textTo=Fields("REF")
textAdd="ABC" & ref1 & "/A"
Fields("REF")=textAdd
SaveRecord
NextRecord
Loop until ref1 = 112

But i can see the problem and it gives every record the ref ABC2/A

Any Ideas????

bert

5-Mar-2012 19:10

Of course an idea....
Not a fast macro, however, it works if you do this.
Remarked lines (beginning with ') you can remove.

ref1 = 1 'first before the loop assign ref1 value 1
Do
EditRecord
'textTo=Fields("REF") --- line remarked - reading the field - does nothing you need

'textAdd="ABC" & ref1 & "/A"
'Fields("REF")=textAdd
'these two lines above you can also do like this:
Fields("REF") = "ABC" & ref1 & "/A"

SaveRecord
NextRecord
ref1 = ref1+1 'here you need to add 1 to var ref1.
Loop until ref1 = 112

halt

regards
bert

Woody123

6-Mar-2012 09:29

Hi Bert,

Thanks for the reply again. Its till justing adding ABC2/A to every field??

Woody123

6-Mar-2012 09:52

Got it working changed the car name from ref1 to just ref.

Thanks again bert dunno what Id do without u.

Cheers !!! :)

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home