Hi,
I have a form with 4 fields.
a) Autonumber
b) ID copied from a previous form
c) Date
d) Integer number
I put the first record and then I press a button that will generated the other records, based on the first. So autonumber is autonumber, ID is copied again for the other records, Date is +1 month and integer is +1.
The problem is that when I press the button, the second record is created but do not trigger the autonumber, so it's like no new record was created. I have to go and do something in the field, retype the number, click and press TAB, etc, so the autonumber is generated and I can save and keep pressing the button to generate the next record.
It's a problem because there is no objective to have a button that generates other records if I have to retype the data again, or do something to trigger the autonumber.
Can't the button trigger the autonumber, so it's like a new record?
Here is the code of the button:
Private Sub NovaDatadePagamento_Click()
On Error GoTo Err_NovaDatadePagamento_Click
Const cQuote = """"
'Date +1 month
Me!DatadePagamento.DefaultValue = cQuote & DateAdd("m", 1, Me!DatadePagamento.Value) & cQuote
'Integer +1
Me!NumerodaParcela.DefaultValue = "'" & Me!NumerodaParcela.Value + 1 & "'"
DoCmd.GoToRecord , , acNewRec
Exit_NovaDatadePagamento_Click:
Exit Sub
Err_NovaDatadePagamento_Click:
MsgBox Err.Description
Resume Exit_NovaDatadePagamento_Click
End Sub