Have form which on repeatedly going to new records just keeps saving them even though nothing is being added, so ending up with lots of empty records.
I've used this procedure to check if the most important field is blank. It sort of works but eventually causes an untidy exit from the form when really I'd just like to leave the form open and allow navigating back to completed records.
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Check if Customer field has been completed; if not don't save
If IsNull(Customer) Then
MsgBox "Customer not entered so record won't be saved"
DoCmd.CancelEvent
Else
DoCmd.Save
End If
End Sub
The form has a number of subforms each with totalled amounts. I'm bringing these up into unbound fields in the main form then using the form's OnCurrent procedure to set bound fields to these values for later reference.
Suspect this is an old chestnut but haven't found any refernce in the FAQs.
I've used this procedure to check if the most important field is blank. It sort of works but eventually causes an untidy exit from the form when really I'd just like to leave the form open and allow navigating back to completed records.
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Check if Customer field has been completed; if not don't save
If IsNull(Customer) Then
MsgBox "Customer not entered so record won't be saved"
DoCmd.CancelEvent
Else
DoCmd.Save
End If
End Sub
The form has a number of subforms each with totalled amounts. I'm bringing these up into unbound fields in the main form then using the form's OnCurrent procedure to set bound fields to these values for later reference.
Suspect this is an old chestnut but haven't found any refernce in the FAQs.