Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a defined range number list with defined steps in a query

Status
Not open for further replies.

kev777

Technical User
Nov 18, 2001
9
GB
Hi,

I am trying to create a sequential list of numbers in a query, i.e. if I put in 3,5,0.5 to a module in a query it would output 3,3.5,4,4.5,5 in 1 column of a query. I have written the following but I don't know how to export the data into a query:

Public Function poprange(rlow As Double, rhigh As Double, rst As Double) As Double
Dim a As Double
For a = rlow To rhigh Step rst
poprange = a
Next
End Function

Please help..

Thanks,

Kev
 
A way to do this:

Code:
Public Function PopRange(rlow As Double, rhigh As Double, rst As Double)

    Dim dbs As DAO.Database
    Dim recset As DAO.Recordset
    Dim a As Double

    Set dbs = CurrentDb
    Set recset = dbs.OpenRecordset("tblNumSeq", dbOpenDynaset)

    For a = rlow To rhigh Step rst
        With recset
            .AddNew
                !SeqNum = a
            .Update
        End With
    Next

End Function

Of course, you need to have the table first, and use YOUR table and field names. Also, the use of te double data type in the for loop is somewhat unusual - but even the use of For loops appears to be gouing out of 'style'. Still, it 'works' - at least until Ms. Changes 'style' to (not) recommended to (not) supported ...

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top