I have a mainform with a continuous subform. The main form is used for data entry using bound controls. I have a save button on the main form with the following code. When I try to clear the main form for a new record, it says 'You can't go to the specified record. and points to the line DoCmd.GoToRecord , , acNewRec.
The goal is to have the main form clear all controls and prepare for new record after any button is pressed and that action has completed. i.e., if you click edit on one if the items in the continous form, the data moves to the main form. Clicking the Delete button does delete the data, but the next record remains on the main form controls instead of a clear for for new records.
DB attached for reference. Thanks!
The goal is to have the main form clear all controls and prepare for new record after any button is pressed and that action has completed. i.e., if you click edit on one if the items in the continous form, the data moves to the main form. Clicking the Delete button does delete the data, but the next record remains on the main form controls instead of a clear for for new records.
DB attached for reference. Thanks!
Code:
Private Sub cmdSave_Click()
'test required fields
If IsNull(Me.txtAirlineCode.Value) _
Or IsNull(Me.txtAirlineCompany.Value) _
Or IsNull(Me.cboProviderName.Value) _
Or IsNull(Me.cboAirlineStatus.Value) Then
MsgBox "Please fill in all required fields."
Else
MsgBox "Record saved."
'Requery forms
Me.Requery
Me.frmAirlineMasterSub.Form.Requery
' Prepare form for new record input
DoCmd.GoToRecord , , acNewRec
End If
End Sub