Hi guys,
I have a split form that only shows records, no edits, adds, or deletions. On the form I have a button "edit", to edit the selected record. It opens a popup form in dialog mode. The popped up form has a "save" and a "cancel" button. The way I need this to work is that no changes should be saved when the cancel button is pressed. Changes should only be saved when the save button is pressed.
To do this I have put the following code into the before update event of the form:
I set blnSaveChanges to false in the form load event, to true in the click event of the save button, and false in the click event of the cancel button.
This seems to work fine when I click the cancel button, changes are discarded. But when I use the save button it saves without checking the required fields and validation rules.
Here is the save button event:
Seems like closing the form like this, causes the validation rules to be ignored. Can anyone tell me how I should do this?
I have a split form that only shows records, no edits, adds, or deletions. On the form I have a button "edit", to edit the selected record. It opens a popup form in dialog mode. The popped up form has a "save" and a "cancel" button. The way I need this to work is that no changes should be saved when the cancel button is pressed. Changes should only be saved when the save button is pressed.
To do this I have put the following code into the before update event of the form:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If (blnSaveChanges) Then
GoTo ExitSub 'do nothing
Else
Cancel = True 'cancel changes
End If
ExitSub:
End Sub
This seems to work fine when I click the cancel button, changes are discarded. But when I use the save button it saves without checking the required fields and validation rules.
Here is the save button event:
Code:
Private Sub cmd_Save_Click()
blnSaveChanges = True
DoCmd.Close acForm, "Receivement_Add", acSaveYes
End Sub
Seems like closing the form like this, causes the validation rules to be ignored. Can anyone tell me how I should do this?