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

  • Thread starter Thread starter Mike C
  • Start date Start date
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.
 
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.
 
Back
Top