Function for Numbering Table - ADO DAO RDO RDS

This is a discussion on Function for Numbering Table - ADO DAO RDO RDS ; How can I make a function that fill automatically a table with numbers : 1 to 500 Regards, Henderson -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...dules/200708/1...

+ Reply to Thread
Results 1 to 4 of 4

Function for Numbering Table

  1. Default Function for Numbering Table

    How can I make a function that fill automatically a table with numbers :
    1 to 500

    Regards,
    Henderson

    --
    Message posted via AccessMonster.com
    http://www.accessmonster.com/Uwe/For...dules/200708/1


  2. Default Re: Function for Numbering Table

    On Mon, 13 Aug 2007 20:02:04 GMT, Marcelo Henderson via
    AccessMonster.com wrote:

    > How can I make a function that fill automatically a table with numbers :
    > 1 to 500
    >
    > Regards,
    > Henderson


    Assuming you already have a table name "tblOfNumbers" with a field
    named "ANumber", Number datatype, Field Size LongInteger (or Integer).

    Change the table and Field names as needed.

    Public Sub FillATable()
    ' Will fill a table field with incremented numbers
    Dim Db As Database
    Dim rs As Recordset
    Dim lgCounter As Long
    Dim intStart As Integer
    Dim intEnd As Integer
    Set Db = CurrentDb

    Set rs = Db.OpenRecordset("tblOfNumbers", dbOpenDynaset)
    intStart = InputBox("From?", "Start with #", 1)
    intEnd = InputBox("To?", "End with #", 500)

    On Error Resume Next
    For lgCounter = intStart To intEnd
    With rs
    .AddNew
    ![ANumber] = lgCounter
    .Update
    End With
    Next lgCounter
    rs.Close
    Set rs = Nothing
    Set Db = Nothing

    End Sub

    --
    Fred
    Please respond only to this newsgroup.
    I do not reply to personal e-mail

  3. Default Re: Function for Numbering Table

    Great

    thanks fredg


    regards
    Henderson

    --
    Message posted via http://www.accessmonster.com


  4. Default RE: Function for Numbering Table

    I just did this today. If you only have 500, there is a simple way to do it.
    Just open the table, put 1 at the frist record and 2 at the second record,
    then immediately (before doing anything else) push the downward arrow key and
    Access will fill the number for you. It is kind of like a spread sheet where
    you fill a couple of numbers and then drag down to populate the reset of the
    cells. It just take a few seconds.

    "Marcelo Henderson via AccessMonster.com" wrote:

    > How can I make a function that fill automatically a table with numbers :
    > 1 to 500
    >
    > Regards,
    > Henderson
    >
    > --
    > Message posted via AccessMonster.com
    > http://www.accessmonster.com/Uwe/For...dules/200708/1
    >
    >


+ Reply to Thread