I'm using a combobox in MS Access to navigate to a data entry and want a msgbox to ask the user whether changes made to the current entry should become saved, undone, or whether the update process should be canceled. The code I run as BeforeUpdate looks as this:
If Me.Dirty = True Then
Select Case MsgBox("Keep changes?", vbYesNoCancel)
Case vbYes
DoCmd.Save
Case vbNo
Me.Undo
Case vbCancel
Cancel = True
End Select
End If
The options Yes and No are working as intended. Though, for some reason I just can't wrap my head around, the Me.undo prevents the event to update as if Cancel would be set to True - meaning: The form stays at the current data and is not going to the select data.
The AfterUpdate event for the combobox simply runs
DoCmd.SearchForRecord , "", acFirst, "[ID] = " & Str(Nz(Screen.ActiveControl, 0))
I also tried to manually control Cancel = False without having any effect.