PDA

View Full Version : "Cancel" Action - Reason required


ecanestrari
Aug 29, 2014, 02:08 AM
Hi there,

I have different forms that are linked to one table (tblDeals) in which I have several fields but in this case I'm interested in two of them ("Status" and "Reason").

On the forms I have a combo box with two values: "Active" and "Cancelled". What I want is that when the "Status" is changed a pop up message appears that will require the user to enter the reason why he changed the status and that information should be saved in the field "Reason".

I know is an Afterupdate event and I'm using the InputBox function but not managing to get it working properly and for the field "Reason"

Thanks in advance,

Regards,

ScottGem
Aug 29, 2014, 04:26 AM
That's not the way I would do it. Have a control bound to the Reason field on your form. In the After Update event of the Status combo use this line of code:

Me.Reason.SetFocus

Assuming reason is the name of control bound to the Reason field.

In the Lost Focus event of that control pit code like:

If IsNull(Me.Reason) Then
MsgBox "You must enter a reason!"
Me.Reason.SetFocus
End If

So when the user changes the status, the Reason control gets the focus. If the user tries to exit the control without entering a reason, they will be told to do so and focus put back in the control. So they won't be able to exit the control without entering a reason.