I need to add a range of records to a table based on the entry of the first record and the entry of the last record. Example: If I enter 123 as the first record and 127 as the last record, I want Access to create records for 124, 125 and 126.
Assume table name is "NumbersBetween" and filed name "MyNumber"
Private Sub Command1_Click()
Dim intMin As Long
Dim intMax As Long
Dim ii As Integer
intMin = DMin("[MyNumber]", "NumbersBetween") + 1
intMax = DMax("[MyNumber]", "NumbersBetween") - 1
DoCmd.SetWarnings False
For ii = intMin To intMax
DoCmd.RunSQL "Insert into NumbersBetween(MyNumber) values(' " & ii & " ')"
Next
DoCmd.SetWarnings True
MsgBox "Numbers are filled!", vbExclamation, "Process completed."
End Sub
Assume table name is "NumbersBetween" and filed name "MyNumber"
Private Sub Command1_Click()
Dim intMin As Long
Dim intMax As Long
Dim ii As Integer
intMin = DMin("[MyNumber]", "NumbersBetween") + 1
intMax = DMax("[MyNumber]", "NumbersBetween") - 1
DoCmd.SetWarnings False
For ii = intMin To intMax
DoCmd.RunSQL "Insert into NumbersBetween(MyNumber) values(' " & ii & " ')"
Next
DoCmd.SetWarnings True
MsgBox "Numbers are filled!", vbExclamation, "Process completed."
End Sub