I have a combo box which contains a list of numbers (1 to 4). On selecting a smaller number I get the Beforeupdate event to count the records in a particular table with a number greater than the new selected number as these records are the ones going to be deleted in the AfterUpdate event. It then asks if you wish to proceed using a Msgbox. If you select "no" the CancelEvent method is called. In theory this should work but the value of the combo box does not revert back to the original value. Can anyone suggest why this occurs and any solution?
The code:
Paul Cooper
The code:
Code:
Private Sub cmb_NumofSets_BeforeUpdate(Cancel As Integer)
Dim ret As Variant
If cmb_set.Value > cmb_NumofSets.Value Then
If DCount("agent", "lists", "set > " & cmb_NumofSets.Value) > 0 Then
ret = MsgBox("This will delete data. Do you wish _
to proceed?", vbYesNo + vbExclamation, "Warning...")
If ret = vbNo Then
DoCmd.CancelEvent
End If
End If
End If
End Sub
Paul Cooper