I have a new record button that runs the code below:
Function NewRecord()
DoCmd.GoToRecord , , acNewRec
End Function
I also have the code below associated with the main form (so it will not update unless all required fields are filled)
Private Sub Form_BeforeUpdate(Cancel As Integer)
' Make sure all required fields are filled in before saving order to table.
' Otherwise, cancel entries made by user.
Dim ctlShipper As ComboBox
Dim cmboSalesPerson As ComboBox
Dim ctlCustomer As ComboBox
Dim ctlShipto As TextBox
Dim ctlReqiredDate As TextBox
On Error GoTo ErrorHandler
Set ctlCustomer = Me!SoldtoName
Set ctlShipper = Me!BranchNumber
Set cmboSalesPerson = Me!Salesperson
Set ctlShipto = Me!ShiptoName
Set ctlRequiredDate = Me!RequiredDate
If IsNull(ctlShipper) Then
MsgBox "Please select FECP Branch.", vbExclamation
Cancel = True
If ctlShipper.Enabled = False Then ctlShipper.Enabled = True
ctlShipper.SetFocus
Exit Sub
End If
If IsNull(cmboSalesPerson) Then
MsgBox "Please select the salesperson for this order.", vbExclamation
Cancel = True
cmboSalesPerson.SetFocus
Exit Sub
End If
If IsNull(ctlCustomer) Then
MsgBox "Please select a Sold To customer.", vbExclamation
ctlCustomer.SetFocus
Cancel = True
Exit Sub
End If
If IsNull(ctlShipto) Then
MsgBox "Please enter Ship to info .", vbExclamation
ctlShipto.SetFocus
Cancel = True
Exit Sub
End If
Exit Sub
ErrorHandler:
MsgBox "Error#: " & Err.Number & vbCrLf & Err.Description
End Sub
When I click the new record button it errors out because of the before update above.
I would like it to give the user the option to cancel or delete the current record (If they decide against completing the order) without jumping into the before update criteria.
Is this possible?
Vince
Function NewRecord()
DoCmd.GoToRecord , , acNewRec
End Function
I also have the code below associated with the main form (so it will not update unless all required fields are filled)
Private Sub Form_BeforeUpdate(Cancel As Integer)
' Make sure all required fields are filled in before saving order to table.
' Otherwise, cancel entries made by user.
Dim ctlShipper As ComboBox
Dim cmboSalesPerson As ComboBox
Dim ctlCustomer As ComboBox
Dim ctlShipto As TextBox
Dim ctlReqiredDate As TextBox
On Error GoTo ErrorHandler
Set ctlCustomer = Me!SoldtoName
Set ctlShipper = Me!BranchNumber
Set cmboSalesPerson = Me!Salesperson
Set ctlShipto = Me!ShiptoName
Set ctlRequiredDate = Me!RequiredDate
If IsNull(ctlShipper) Then
MsgBox "Please select FECP Branch.", vbExclamation
Cancel = True
If ctlShipper.Enabled = False Then ctlShipper.Enabled = True
ctlShipper.SetFocus
Exit Sub
End If
If IsNull(cmboSalesPerson) Then
MsgBox "Please select the salesperson for this order.", vbExclamation
Cancel = True
cmboSalesPerson.SetFocus
Exit Sub
End If
If IsNull(ctlCustomer) Then
MsgBox "Please select a Sold To customer.", vbExclamation
ctlCustomer.SetFocus
Cancel = True
Exit Sub
End If
If IsNull(ctlShipto) Then
MsgBox "Please enter Ship to info .", vbExclamation
ctlShipto.SetFocus
Cancel = True
Exit Sub
End If
Exit Sub
ErrorHandler:
MsgBox "Error#: " & Err.Number & vbCrLf & Err.Description
End Sub
When I click the new record button it errors out because of the before update above.
I would like it to give the user the option to cancel or delete the current record (If they decide against completing the order) without jumping into the before update criteria.
Is this possible?
Vince