Question about a consecutive number loop

  • Thread starter Thread starter Lost
  • Start date Start date
L

Lost

I do not even know if this is possible.

I would like to ask the user for two number a start number and a end number.

After that populate a table with the start number and all of the number till
it hits the end number.

Basical if the user says 1 and 10 it will put in a table 1,2,3,4,5,6,7,8,9,10.

What it is to be used for is to print out bar code identification labels and
I know that i can set up a database that already has the numbers in it and do
a query but the database jumped drasticaly in size.

Thank you in advance
 
I do not even know if this is possible.

I would like to ask the user for two number a start number and a end number.

After that populate a table with the start number and all of the number till
it hits the end number.

Basical if the user says 1 and 10 it will put in a table 1,2,3,4,5,6,7,8,9,10.

What it is to be used for is to print out bar code identification labels and
I know that i can set up a database that already has the numbers in it and do
a query but the database jumped drasticaly in size.

Thank you in advance

Create a new table.
Table Name .... tblNumbers
FieldName ..... TheNumber Number Datatype Field Size Long Integer


Copy and paste the below code into a module.

Run the code.
It will fill the table with consecutive numbers.

Public Sub FillNumbers()
Dim lngX As Long
Dim lngFrom As long
Dim lngTo As long

lngFrom = InputBox("Start at number?", , 1)
lngTo = InputBox("End at number?")
For lngX = lngFrom To lngTo
CurrentDb.Execute "Insert into tblNumbers ([TheNumber]) Values(" _
& lngX & ");", dbFailOnError
Next lngX

End Sub
 
Thank You Very Much that worked perfect.



fredg said:
I do not even know if this is possible.

I would like to ask the user for two number a start number and a end number.

After that populate a table with the start number and all of the number till
it hits the end number.

Basical if the user says 1 and 10 it will put in a table 1,2,3,4,5,6,7,8,9,10.

What it is to be used for is to print out bar code identification labels and
I know that i can set up a database that already has the numbers in it and do
a query but the database jumped drasticaly in size.

Thank you in advance

Create a new table.
Table Name .... tblNumbers
FieldName ..... TheNumber Number Datatype Field Size Long Integer


Copy and paste the below code into a module.

Run the code.
It will fill the table with consecutive numbers.

Public Sub FillNumbers()
Dim lngX As Long
Dim lngFrom As long
Dim lngTo As long

lngFrom = InputBox("Start at number?", , 1)
lngTo = InputBox("End at number?")
For lngX = lngFrom To lngTo
CurrentDb.Execute "Insert into tblNumbers ([TheNumber]) Values(" _
& lngX & ");", dbFailOnError
Next lngX

End Sub
 
Back
Top