Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Delete Warning Message

When I use Send_Event(@Window, "DELETE"), I will always get a system message to verify that the user really wants to delete the record. Is it possible to bypass this system message?

Comments

  • HI Dan,

    I honestly don't think you can do this directly. The DELETE event itself does not have a suppressWarning argument the same way the CLEAR event does. I think you best bet is to use the CLEAR event handler (with the suppressWarning argument set to True), and then delete the row using the Delete or the Delete_Row subroutine.
  • Dan,

    You can also trap the SYSMSG event handler and return a 0 so the SYSMSG system event handler does not process the message box. Since you have to intercept this before the system event handler, you would either need to do this in a script event handler or in a promoted SYSMSG event handler.
  • I have not worked with the SYSMSG event handler before, but I had attempted to do exactly what you suggested. I have no trouble trapping the event with a script event handler, but there is no indication on the parameters of the event which system message is being sent. In the documentation it states that the parameter msgCode should be one of the equates in the PS_EQUATES, with DELETEWARN$ being the value I am looking for. I found that the PS_EQUATES does not contain a value of DELETEWARN$, but rather SYSMSG_DELETEWARN$. I found further that the event handler is sending null for the parameter msgCode. My only option that I can see is to return 0 on all SYSMSG events, but that seems like it would stop all system messages, which I'm not sure is such a good idea. How can I only stop the DELETEWARN$ message?
  • Dan,

    When I did my proof of concept testing on this, I found that the MsgCode argument was populated with a value of 2 (SYSMSG_DELETEWARN$). I'm not sure why you are getting a null other than perhaps you just happen to be catching other system messages that do not populate this argument (which still seems strange).

    My first advice is to just test for the SYSMSG_DELETEWARN$ value. Does this ever come up when you send the DELETE event to the form?

    If you manage to trap this, then you need to decide if you always want to disable the Delete Warn message or only under certain conditions. If the latter, then I recommend creating a user-defined property in your code that sends the DELETE event and then check this UDP in your SYSMSG event handler. That way you can limit the functionality to both the specific system message and to specific conditions. Just make sure you clear the UDP so this does not affect future activities.

    To suppose the message box itself, just return a 0. To allow the message box to appear then return a 1.
  • Okay - I found where I had not passed the MsgCode parameter correctly in my script event handler. The solution works great. Thanks for the help!
Sign In or Register to comment.