Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Converting a range of numbers to individual numbers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Smythe32@aol.com - 30 Nov 2006 04:11 GMT
Hi,

I was hoping someone could help me out here with some code.  I need to
take a starting number and an ending number and produce a list of all
the numbers in between.

Ex:
Start_Num    End_Num
2345611000    2345611005
5856378700    5855378703
7162251601    7162251601

I would like these to append to another table.  For example once the
above are broken out, the following would append to a current table.

2345611000
2345611001
2345611002
2345611003
2345611004
2345611005
5856378700
5856378701
5856378702
5856378703
7162251601

Thanks in advance.
Allen Browne - 30 Nov 2006 04:30 GMT
See the MakeData() function at the end of this article:
   http://allenbrowne.com/ser-39.html

You could change the first line:
   Function MakeData()
to:
   Function MakeData(Start_Num As Long, End_Num As Long)
and the line:
   For lng = 1 to conMaxRecords
to
   For lng = Start_Num to End_Num

Change the table name, and call the function to add the records.

Signature

Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Hi,
>
[quoted text clipped - 24 lines]
>
> Thanks in advance.
Marshall Barton - 30 Nov 2006 17:01 GMT
>I was hoping someone could help me out here with some code.  I need to
>take a starting number and an ending number and produce a list of all
[quoted text clipped - 20 lines]
>5856378703
>7162251601

If you aready have Allen's tblCount and the start/end values
are in table tblStartEnd, then you could do it all with a
query:

INSERT INTO anothertable
SELECT tblStartEnd.Start_Num + tblCount.CountID -1
FROM  tblStartEnd, tblCount
WHERE tblStartEnd.Start_Num + tblCount.CountID - 1
                                                    <= tblStartEnd.End_Num

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.