Hello,
I need to create and assign a stock of documents numbers by office. This numbers should be stored in a "Qry_Store_DocNumber_By_Oficce" Query.
Exemple:
Form
Clicking the "assign and Create Stock" button should be created in "Qry_Store_DocNumber_By_Oficce" query, 5 records (11111 19999, 11111 20000, 11111 20001, 11111 20002 and 11111 20003), documents assigned to the office " Office test".
I did the procedure below but is not working.
Private Sub IncrementaStock_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim vlr As String
Dim Qtd As Long
Dim CpOffice As Integer
Dim CpIdBilhete As Integer
Dim i As Long
Set db = CurrentDb()
Set rs = db.OpenRecordset("Qry_Store_DocNumber_By_Oficce")
vlr = Me.DocNumber.Value - 1
Qtd = Me.Amount.Value
CpIDOffice = Me.IDOffice.Value
CpIdDoc = Me.IdDoc.Value
For i = 1 To Me.Amount.Value
rs.AddNew
rs("DocNumber") = vlr + i
rs("Amount") = Qtd - i + i
rs("IdOffice") = CpOffice
rs("IdDoc") = CpIdBilhete
rs.Update
Next
MsgBox ("Bilhetes Gerados!!!!")
rs.Close
db.Close
End Sub
Please Help!