A family of Microsoft relational database management systems designed for ease of use.
As you have found out an append query is a set operation. To do this sort of thing the set has to have one member only, so you need to execute the query multiple times, appending one row each time. This is done by executing the INSERT INTO statement in a loop. You'll find an example in CustomNumber.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
This little demo file includes an illustration of how to insert sequentially numbered multiple rows, in this case one for each item selected in a multi-select list box. The code to do this is as follows:
Private Sub cmdInsert_Click()
Const KEYVIOLATION = 3022
Dim ctrl As Control
Dim varItem As Variant
Dim strSQL As String
Dim strMessage As String
Dim lngNextID As Long
Dim lngSeed As Long
Dim intCurrentRows As Integer
Dim intNewRows As Integer
Set ctrl = Me.lstTools
lngNextID = Nz(DMax("ProductID", "Product"), 0) + 1
lngSeed = Nz(DLookup("Seed", "Seeds"), 0)
intCurrentRows = DCount("*", "Product")
If lngSeed > lngNextID Then
lngNextID = lngSeed
End If
For Each varItem In ctrl.ItemsSelected
strSQL = "INSERT INTO Product(ProductID, ProductName, Category) " & _
" SELECT " & lngNextID & ", Tool, Category " & _
"FROM Tools WHERE Tool = """ & ctrl.ItemData(varItem) & """"
On Error Resume Next
CurrentDb.Execute strSQL, dbFailOnError
Select Case Err.Number
Case 0
' no error
Case KEYVIOLATION
Do While Err.Number <> 0
lngNextID = DMax("ProductID", "Product") + 1
strSQL = "INSERT INTO Product(ProductID, ProductName, Category) " & _
"SELECT " & lngNextID & ", Tool, Category " & _
"FROM Tools WHERE Tool = """ & ctrl.ItemData(varItem) & """"
CurrentDb.Execute strSQL, dbFailOnError
Err.Clear
Loop
Case Else
' unknown error
MsgBox Err.Description, vbExclamation, "Error"
Exit Sub
End Select
lngNextID = DMax("ProductID", "Product") + 1
Next varItem
intNewRows = DCount("*", "Product")
strMessage = (intNewRows - intCurrentRows) & _
" rows were inserted."
MsgBox strMessage, vbInformation, "Confirmation"
End Sub