Skip to Content

Problem with Option Buttons and Event Handler

Hi, everybody

Please see the attached picture which summarizes my problem.

My code for the Event Handler is as foll:

Private Sub OnBeforeB_OKPressed(ByVal Source As Object, ByVal pVal As SAPbouiCOM.SBOItemEventArg, ByRef Bubble As Boolean)

If O_CrRq.Selected = True And O_ToShp.Selected = True Then

If C_ToShip.Value <> "" Then

SBO_Application.MessageBox("OK! ")

Else

SBO_Application.MessageBox("Error! You have not selected a ship!")

End If

End If


------

My code is too lengthy to post here. So, I am not sure I have given you all the relevant information.

Also, I can expect only general answers, or hints to help me investigate further.

------

Any comments, or hints are most welcome

Thanks

Leon

Capture.JPG (221.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 04, 2016 at 09:51 AM

    Hi Leon,


    I adise you to check the Linked DataSources values instead of using the Item Value.


    For Exemple,

    Instead of checking the Radio Button Value, check it's linked DataSource like That :


    if oForm.DataSources.UserDataSources.Item("O_CrRq ").Value == 'Y' then.


    You do that also for the Combobox Value :


    Not String.IsNullOrEmpty(oForm.DataSources.UserDataSources.Item("C_ToShip").Value)


    Hope it helps


    Regards

    Mohamed BEGAA

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Mohamed and Pedro,

      Thank you both for your help.

      I have found the solution to my problem by using BOTH your suggestions.

      The problem was in the Combo. I assumed its value was BLANK i.e "".

      I forgot that it could also be a NULL.

      Also, I checked the value of the USERDATASOURCE instead of the value of the COMBO.

      I don't know why UDS.VALUE works, but COMBO.VALUE does not in my project. Maybe someone can explain?

      Here is the final solution- which works!

      Best Regards,

      Leon

      Private Sub OnBeforeB_OKPressed(ByVal Source As Object, ByVal pVal AsSAPbouiCOM.SBOItemEventArg, ByRef Bubble As Boolean)

      If O_CrRq.Selected = True And O_ToShp.Selected = True Then

      ‘// If C_ToShip.Value <> "" Then

      If Not String.IsNullOrEmpty(FormSelx.DataSources.UserDataSources.Item(“UDS_Combo”).Value Then

      SBO_Application.MessageBox("OK You have selected a ship! ")

      Else

      SBO_Application.MessageBox("Error! You have not selected a ship!")

      End If

      End If

  • Apr 04, 2016 at 09:02 AM

    Hi Leon,

    Do you have any items on the combobox? I'd change the C_ToShip.Value <> "" to

    Not String.IsNullOrEmpty(C_ToShip.Value)


    Best regards,

    Pedro Magueija


    View Pedro Magueija's profile on LinkedIn

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Leon,

      If a message box displays then the first condition is evaluated to true (which means the O_CrRq is evaluated correctly). Your problem (if the description is accurate) must be in the second condition.

      You can set a breakpoint in the code and then just check what are the actual values. This will give you an idea of what is going on.

      ps: Former Member is right about using the datasources (rather then UI), I'd recommend fixing your issue then refactoring to use the datasources.


      Best regards,

      Pedro Magueija


      View Pedro Magueija's profile on LinkedIn