Creating list of records by given range of numbers (1 Viewer)

Jonny

Registered User.
Local time
Today, 23:43
Joined
Aug 12, 2005
Messages
144
I have a range of board serial numbers, starting from SN0000001 and till SN0001000.
How can I create automatically 1000 records, what the VBA code to do that?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:43
Joined
Aug 30, 2003
Messages
36,139
You can open a recordset on the target table, and use a For/Next loop with your starting and ending numbers. Within the loop, use the AddNew method of the recordset to add a record.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 06:43
Joined
Jan 20, 2009
Messages
12,863
If all values start with SN you should not include that in the stored value. Only store the number and display the SN and zero padding by using the Format property of the control where it is displayed on the form or report.

Type this into the Format property:
"SN"0000000

It is much easier to increment a number than a string and much faster for Access to work with a number field.
 

Users who are viewing this thread

Top Bottom