Hello,
I am trying to write a code, to create a 2nd record while the current record is being created. I have written this code in the command_click event of the last button ('Exit Form' button) that is clicked on the form to close it.
I want to create a new record (or 2nd record) if the value of a particular textbox is < 25 (i.e. continue with creating the current record based on the values entered in the open form and also create a second record if the width entered happens to be less than 25). The new record should have the same values as the current record that is being created, except for the primary key and few other fields. The primary key (RollCut) will be XXXXX-1 for 1st record and XXXXX-2 for 2nd record (XXXXX being the value of "Ticket" field).
-----------------
Private Sub Command105_Click()
On Error GoTo Err_Command105_Click
If Me.WbWidth.Value < 25 Then
DoCmd.GoToRecord , , acNewRec
'Add statement to use same values as the current record
[RollCut] = [Ticket] & "-2"
'Add statements to change some of the values in 2nd record.
End If
DoCmd.Close
Exit_Command105_Click:
Exit Sub
Err_Command105_Click:
MsgBox Err.Description
Resume Exit_Command105_Click
End Sub
------------------
I also get an error message, "you can't go to the specified record". Can anyone please help me with the code?
Thanks,
JK