You can use the AddNew method of a recordset and a For/Next loop that uses the form textboxes.
Thank you sir. It took me a few hours solving it since I'm new with access.
Private Sub cmdinput_Click()
'here is my code just in case someone has the same problem hope this help.
Dim LCounter As Integer
Dim ID As Long
DoCmd.GoToRecord , , acNewRec
Text19 = Me.txtbegining
For LCounter = Me.txtbegining To (Me.txtend - 1)
DoCmd.GoToRecord , , acNewRec
ID = DMax("sampleID", "sample")
Text19 = DLookup("serial_number", "sample", "sampleID=" & ID) + 1
Next
DoCmd.Requery
End Sub
Why not just use the LCounter value to set the value? Your code would not necessa use the values from the form.
Here is an alternative:
Code:Option Compare Database Option Explicit Private Sub cmdinput_Click() Dim LCounter As Integer Dim lngBegining As Long Dim lngEnd As Long Dim sSQL As String 'get starting and ending numbers lngBegining = Me.txtbegining lngEnd = Me.txtend For LCounter = lngBegining To lngEnd sSQL = "INSERT INTO sample(serial_number) VALUES (" & LCounter & ");" CurrentDb.Execute sSQL, dbFailOnError Next DoCmd.Requery End Sub