How to fill fill a column with numbers, beginning at number X,counting up.

M

Mike C

I simply need to add numbers, beginning with 15,347, (counting
upward), to a column with empty values in a table.

Is there an easy way to do this, rather than completing it in excel
and importing it, then attempting to update the table?

Thanks for any suggestions.
 
D

Douglas J. Steele

While I cannot imagine a legitimate use for this, the following code will
insert rows starting at 15347 and going to 22000

Dim dbCurr As DAO.Database
Dim lngLoop As Long
Dim strSQL As String

Set dbCurr = CurrentDb

For lngLoop = 15347 To 22000
strSQL = "INSERT INTO MyTable (MyField) " & _
"VALUES (" & lngLoop & ")"
dbCurr.Execute strSQL, dbFailOnError
Next lngLoop

Set dbCurr = Nothing

Prepopulating tables is seldom (if ever) appropriate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top