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