TagNo: 41
Qty: 5
Vendor: Amazon
ModelName: HP-Azkaban
At the click of the button I want this output:
Amazon HP-Azkaban 41
Amazon HP-Azkaban 42
Amazon HP-Azkaban 43
Amazon HP-Azkaban 44
Amazon HP-Azkaban 45
Instead I get this:
Amazon HP-Azkaban 41
Amazon HP-Azkaban 41
Amazon HP-Azkaban 41
Amazon HP-Azkaban 41
Amazon HP-Azkaban 41
So far I have a sub with a call to a function that is supposed to change the number each time the append query runs.
Sub:
Expand|Select|Wrap|Line Numbers
- Private Sub AddItems_Click()
- Dim aSQL As String
- Dim TN As Integer
- Dim Q As Integer
- TN = Me.TagNo
- Q = Me.Qty
- aSQL = "INSERT INTO tblItems ( Vendor, ModelName, TagNo )"
- aSQL = aSQL & " VALUES ('" & Me.Vendor & "', " & Me.ModelName & ", " & SetTagNo(X) & ") "
- For n = 1 To Q
- CurrentDb.Execute aSQL, dbFailOnError
- TN = TN + 1
- Next n
- Exit Sub
Expand|Select|Wrap|Line Numbers
- Function SetTagNo(X As Variant) As Integer
- Static intTN As Integer
- If intTN = 0 Then
- intTN = Forms!frmPurchases!TagNo - 1
- End If
- intTN = intTN + 1
- SetTagNo = intTN
- End Function
Doug