A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old March 16th, 2008, 06:32 PM posted to microsoft.public.access
Mike C[_5_]
external usenet poster
 
Posts: 16
Default How to fill fill a column with numbers, beginning at number X,counting up.

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.
  #2  
Old March 16th, 2008, 09:27 PM posted to microsoft.public.access
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default How to fill fill a column with numbers, beginning at number X, counting up.

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.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Mike C" wrote in message
...
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.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:33 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.