on 02-09-2015 11:28 AM
Hi,
I have created a form with Option Buttons, Edit Boxes and a Combo Box.
The main function of this form is to pass parameters to one or more stored procedures (SQL)
Below is a picture of my form. The names of some of the items are shown.
I can execute a stored procedure and pass parameters as for example:
StrQuery = "Exec [dbo].[usp_HandOver3]" & "'" & i_Tag & "'" & "," & "'" & oDocCount & "'"
But I don't know how to capture the names of the Option Buttons etc so as to pass them as parameters.
Can anybody help? It may suffice if you outline the main points to be followed.
Thanks
Leon Lai
----------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pedro,
Thanks for your reply.
Yes, I want to know which button is selected.
For example, if the radio button "OptShip" is clicked, I want to save the string "OptShip" to a variable called "WhichStore". Same for the other buttons in the box.
If the radio button "OptOrig" is clicked, I want to save the string "OptOrig" to a variable called "PrefSortOrder"
There will be 6 variables in all (WhichStore, WhichReport, PrefSortOrder, FromDt, ToDate, Project),
and each variable will contain a value depending on which button, etc is selected.
When I press "Update", this will execute a stored procedure and pass these 6 parameters to it.
Best Regards,
Leon Lai
Hi Leon,
To check if a option button is selected you can use the property Selected from the SAPbouiCOM.OptionBtn object.
You can either put the value into your variable when you press the Update button (you'll have to check which button is selected), or you can capture the PressedAfter events of the option buttons and fill the variable according to the button that got pressed.
Best regards,
Pedro Magueija
Hi Leon,
Below are the steps to set up option buttons
I assume I am setting up as below :
1. Create the buttons, either via codes/Screen Painter/B1 Studio.
2. I would name them opt11, opt12, opt13, opt14 and opt21, opt22, opt23, opt24 respectively for group 1 and 2.
3. Add two datasources named "opt1" and "opt2" with datatype short text, size 10
4. Add below code to initialize the options.
SAPbouiCOM.OptionBtn oOpt = _oForm.Items.Item("opt11").Specific as SAPbouiCOM.OptionBtn;
oOpt.DataBind.SetBound(true, "", "opt1");
oOpt.ValOn = "11";
oOpt = _oForm.Items.Item("opt12").Specific as SAPbouiCOM.OptionBtn;
oOpt.DataBind.SetBound(true, "", "opt1");
oOpt.GroupWith("opt11");
oOpt.ValOn = "12";
oOpt = _oForm.Items.Item("opt13").Specific as SAPbouiCOM.OptionBtn;
oOpt.DataBind.SetBound(true, "", "opt1");
oOpt.GroupWith("opt11");
oOpt.ValOn = "13";
oOpt = _oForm.Items.Item("opt14").Specific as SAPbouiCOM.OptionBtn;
oOpt.DataBind.SetBound(true, "", "opt1");
oOpt.GroupWith("opt11");
oOpt.ValOn = "14";
oOpt = _oForm.Items.Item("opt21").Specific as SAPbouiCOM.OptionBtn;
oOpt.DataBind.SetBound(true, "", "opt2");
oOpt.ValOn = "21";
oOpt = _oForm.Items.Item("opt22").Specific as SAPbouiCOM.OptionBtn;
oOpt.DataBind.SetBound(true, "", "opt2");
oOpt.GroupWith("opt21");
oOpt.ValOn = "22";
oOpt = _oForm.Items.Item("opt23").Specific as SAPbouiCOM.OptionBtn;
oOpt.DataBind.SetBound(true, "", "opt2");
oOpt.GroupWith("opt21");
oOpt.ValOn = "23";
oOpt = _oForm.Items.Item("opt24").Specific as SAPbouiCOM.OptionBtn;
oOpt.DataBind.SetBound(true, "", "opt2");
oOpt.GroupWith("opt21");
oOpt.ValOn = "24";
5. The code above will bind the two sets of options with my datasource and group them together.
I am also giving a value for each of the option button using the oOpt.ValOn property.
6. When the user pressed the update button, you would catch the item pressed event of this update button and review the opt1 and opt2 datasource value.
7.
System.Diagnostics.Debug.WriteLine(String.Format("Option 1 Value : {0}", _oForm.DataSources.UserDataSources.Item("opt1").ValueEx));
System.Diagnostics.Debug.WriteLine(String.Format("Option 2 Value : {0}", _oForm.DataSources.UserDataSources.Item("opt2").ValueEx));
8. The datasource opt1 and opt2 should give you the assigned ValOn value of the selected option button.
Good Luck,
Edy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.