Binding textbox to combobox selected value when the selected value is blank

I have a simple form that binds data to a combobox and when one of the values in the combobox is selected it fills a textbox with the corresponding column in that table.  However, if that combobox value is empty(meaning that table cell is empty) then
the textbox will not fill with the correct value.  I am finding this hard to explain so I will lay it out.
The table[COA] is as follows:
ID
Fund
Fund Description
Bus Unit
Bus Unit Description
Obj
Obj Description
Sub
PEC
1
2789
Account Refund
10000
General Fund
1500
ASC Voucher
10
2
2789
Account Refund
10000
General Fund
1500
Voucher
The following is my code:
private void subComboBox_SelectedIndexChanged(object sender, EventArgs e)
pECTextBox.Clear();
using (SqlConnection connection = new SqlConnection(@"Data Source=MARYANNEBORJA\SQLEXPRESS;Initial Catalog=jdeDatabase;Persist Security Info=True;User ID=Jordan;Password=*****"))
SqlCommand command = new SqlCommand("SELECT * FROM [COA] WHERE [Bus Unit]='" + bus_UnitComboBox.Text + "' AND [Obj] ='" + objComboBox.Text + "'AND [Sub] ='" + subComboBox.Text + "'");
command.Connection = connection;
connection.Open();
SqlDataReader read = command.ExecuteReader();
while (read.Read())
if (!read.IsDBNull(8))
pECTextBox.Text = (read["PEC"].ToString());
else
pECTextBox.Text = "";
obj_DescriptionTextBox.Text = (read["Obj Description"].ToString());
read.Close();
I fill my combobox with Sub values based on the Bus Unit and Obj.  Since the Bus Unit and the Obj in both rows are the same the combobox is filled with 10 and "".  
Here is where the problem occurs.  When I select "10" in the combobox I want a textbox to fill with correct Obj Description field.  So selecting "10" would give me 'ASC Voucher' in the textbox and selecting "" should
give me 'Voucher' in the textbox, but this is not the case.  I can only get 'ASC Voucher' to fill the textbox.  When I select "" it keeps the textbox at 'ASC Voucher'.
My guess us that is has something to do with the value being empty in that table cell because when I am selecting other values it works.  
Any guess as to what I should do?

Hi objectifyThat,
When Your subComboBox.Text is null, you should use "Sub is null" in your SQL like below.
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
pECTextBox.Clear();
using (SqlConnection connection = new SqlConnection(@"Data Source=MARYANNEBORJA\SQLEXPRESS;Initial Catalog=jdeDatabase;Persist Security Info=True;User ID=Jordan;Password=*****"))
string cmdstring = "SELECT * FROM [COA] WHERE [Bus Unit]='" + bus_UnitComboBox.Text + "' AND [Obj] ='" + objComboBox.Text + "'AND [Sub] ='" + subComboBox.Text + "'";
if (string.IsNullOrEmpty(subComboBox.Text))
cmdstring = "SELECT * FROM [COA] WHERE [Bus Unit]='" + bus_UnitComboBox.Text + "' AND [Obj] ='" + objComboBox.Text + "'AND [Sub] Is Null";
SqlCommand command = new SqlCommand(cmdstring);
command.Connection = connection;
connection.Open();
SqlDataReader read = command.ExecuteReader();
while (read.Read())
if (!read.IsDBNull(8))
pECTextBox.Text = (read["PEC"].ToString());
else
pECTextBox.Text = "";
obj_DescriptionTextBox.Text = (read["Obj Description"].ToString());
read.Close();
If you have any other concern regarding this issue, please feel free to let me know.
Best regards,
Youjun Tang
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Value help for select options  (pass the selected values to the select opt)

    Hi everyone,
    I created a custom value help for my select options.
    It works fine, when the user clicks on the value help, my own view is displayed, and the user can select the required values:
    lt_range_table =
      wd_this->m_handler->create_range_table(
      i_typename = 'ORGEH' ).
    * add a new field to the selection
      wd_this->m_handler->add_selection_field(
      i_id = 'ORGEH'
      i_value_help_id = 'MYSO'
      i_value_help_type = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_APPLDEV
      it_result = lt_range_table
      i_read_only = read_only ).
    The problem is, how can I pass the values to the select option? When the user selects the values in my view, I have them in an internal table. But how can i pass these values to the select option?  I suppose there is declared method for this... but which one?
    Thanks
    N.

    Sorry for the stupid question, but it seems I can't acces my attribute:
    I create it in the component controller
    NODE: 'APP_DATA'
    Attribute: M_HANDLER TYPE IF_WD_SELECT_OPTIONS
    Cardinality 1..1
    Selection 1..1
    Singleton = 'X'
    I pass the values int he EDOINIT method of MAIN view:
    * Get compnent controller API
      lo_component = wd_comp_controller->wd_get_api( ).
      lo_controller ?= lo_component.
    * Get the controler context node
      CALL METHOD LO_CONTROLLER->GET_CONTEXT
        RECEIVING
          CONTEXT = lo_context.
    *Get the root node
      lo_node = lo_context->root_node.
    *Get the child node
      lo_child = lo_node->get_child_node( 'APP_DATA' ).
    ls_app_data-m_handler = wd_this->m_handler.
    lo_child->bind_structure( ls_app_data  ).
    After this code I test it if the binding is correct:
    DATA: ls_test TYPE wd_comp_controller->element_app_data.
    CALL METHOD LO_CHILD->GET_STATIC_ATTRIBUTES
      IMPORTING
        STATIC_ATTRIBUTES = ls_test.
    The lstest is correct_. It has the reference for the SelectOption
    Now, in the SEL_TREE View:
    * Get compnent controller API
      lo_component = wd_comp_controller->wd_get_api( ).
      lo_controller ?= lo_component.
    * Get the controler context node
      CALL METHOD LO_CONTROLLER->GET_CONTEXT
        RECEIVING
          CONTEXT = lo_context.
    *Get the root node
      lo_node = lo_context->root_node.
    *Get the child node
      lo_child = lo_node->get_child_node( 'APP_DATA' ).
    *Get the data from the node
      CALL METHOD LO_CHILD->GET_STATIC_ATTRIBUTES
        IMPORTING
          STATIC_ATTRIBUTES = ls_app_data.
      wd_this->m_handler = ls_app_data-m_handler.
    The ls_app_data-m_handler is INITIAL. There is no value in it.
    What did I do wrongly? 
    Please help
    Thanks
    N.

  • Problems with query with more than 20 values in the select clause

    I have a region based on a function returning a SQL query. It needs to have more than 20 values in the select clause. When I run the page I get a no data found error in the region. I managed to reproduce this behavior with just the following as the select returned by the function:
    select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21
    from dual
    I am running the 1.3.9.00.15 release of Marvel on 9.2.0.2 of the db on Solaris.

    Hello Raju,
    I will email you the connection settings when I return to the office.
    One thing I should have mentioned: The sql string is returned from a package in the db, so the query region text I originally posted isn't quite correct.
    it is something like:
    declare
    begin
    return my_pkg.my_fnc;
    end;
    the stored package is nothing more than:
    package my_pks is
    funtion my_fnc(i_test_param in varchar2) is
    begin
    return 'select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, 21 from dual';
    end;
    end;
    Sorry for the inaccurate info in the first post, but I am away from the server in question right now.

  • Select options -restricting the operator value options.

    Hi,
    In selection screen for the  select options or parameter declarations  I need to restrict the operator options , like when they click for any select options it will give options to select = , #, <, <= , > , >=
    all these options right.
    I would like to restrict the user  to select only > and >=  while passing values.
    Can anyone give me idea how I can approach this?
    Thanks in advance.

    Hi,
    use this FM...
    SELECT_OPTIONS_RESTRICT can be use to supress options available with a SELECT-OPTIONS on a selection screen.
    jusy copy the code and execute it....It will give the exact output what u want.....
    TYPE-POOLS sscr.
    TABLES : marc.
    *Define the object to be passed to the RESTRICTION parameter
    DATA restrict TYPE sscr_restrict.
    *Auxiliary objects for filling RESTRICT
    DATA : optlist TYPE sscr_opt_list,
    *** TYPE sscr_***.
    *Defining the selection-screen
    SELECT-OPTIONS : s_matnr FOR marc-matnr,
    s_werks FOR marc-werks.
    INITIALIZATION.
    *Restricting the MATNR selection to only EQ and 'BT'.
    optlist-name = 'OBJECTKEY1'.
    optlist-options-eq = 'X'.
    optlist-options-bt = 'X'.
    APPEND optlist TO restrict-opt_list_tab.
    ***-kind = 'S'.
    ***-name = 'S_MATNR'.
    ***-sg_main = 'I'.
    ***-sg_addy = space.
    ***-op_main = 'OBJECTKEY1'.
    APPEND *** TO restrict-***_tab.
    *Restricting the WERKS selection to CP, GE, LT, NE.
    optlist-name = 'OBJECTKEY2'.
    optlist-options-cp = 'X'.
    optlist-options-ge = 'X'.
    optlist-options-lt = 'X'.
    optlist-options-ne = 'X'.
    APPEND optlist TO restrict-opt_list_tab.
    ***-kind = 'S'.
    ***-name = 'S_WERKS'.
    ***-sg_main = 'I'.
    ***-sg_addy = space.
    ***-op_main = 'OBJECTKEY2'.
    APPEND *** TO restrict-***_tab.
    CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    EXPORTING
    restriction = restrict
    EXCEPTIONS
    too_late = 1
    repeated = 2
    selopt_without_options = 3
    selopt_without_signs = 4
    invalid_sign = 5
    empty_option_list = 6
    invalid_kind = 7
    repeated_kind_a = 8
    OTHERS = 9.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Regards
    Kiran

  • Msg 116, Level 16, State 1, Line 6 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

    Hello,
    Can anyone help me?
    select year(po.rdata) as 'Ano', 
    sum(etotal) as 'Valorp' ,
    (select year(fo.data),Sum(etotal) 
    FROM fo (nolock) 
    where  not exists ( select 1 from pl (nolock) where pl.adoc = fo.adoc and pl.cm = fo.doccode ) 
    group by year(fo.data))as 'Valorap'   
    from po 
    group by year(po.rdata)
    order by year(po.rdata)
    Error 
    Msg 116, Level 16, State 1, Line 6
    Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
    Consultora

    Hi Prashanth,
    select year(po.rdata) as 'Ano',
    sum(etotal) as 'Valorp' ,
    (select Sum(etotal)
    FROM fo (nolock)
    where not exists ( select 1 from pl (nolock) where pl.adoc = fo.adoc and pl.cm = fo.doccode )
    group by year(fo.data))as 'Valorap'
    from po(nolock)
    group by year(po.rdata)
    order by year(po.rdata)
    Gives me the error: 
    Msg 512, Level 16, State 1, Line 1
    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
    Thanks
    Consultora

  • How to get all the values in the Select-option.

    Hi,
    I got the select-option field so_week, for eg. If I give 200923 to 200926 (year and week)  in the selection screen and then I need to pass this value (200923) to the FM 'ZWEEK_GET_FIRST_DAY' to get the first day of the week.
    My question is how can i get all the values from the select option, (i.e) i need to get 200923, 200924,200925, 200926.
    Regards,
    Anbu.

    Hello,
    I will prefer Max's solution. But just for the sake of this req.
    i need to get 200923, 200924,200925, 200926
    i am proposing my soln:
    DATA: V_WEEK TYPE RSCALWEEK.
    SELECT-OPTIONS: S_WEEK FOR V_WEEK NO-EXTENSION OBLIGATORY.
    AT SELECTION-SCREEN.
      DATA:
      V_COUNT TYPE I,
      V_ADD   TYPE I,
      RT_WEEK TYPE RANGE OF RSCALWEEK,
      RS_WEEK LIKE LINE OF RT_WEEK.
      V_COUNT = ( S_WEEK-HIGH - S_WEEK-LOW ) + 1.
      DO V_COUNT TIMES.
        RS_WEEK-SIGN = 'I'.
        RS_WEEK-OPTION = 'EQ'.
        RS_WEEK-LOW = S_WEEK-LOW + V_ADD.
        APPEND RS_WEEK TO RT_WEEK. "RT_WEEK--> Will contain the week values
        CLEAR RS_WEEK.
        V_ADD = V_ADD + 1.
      ENDDO.
    @Max: I was stupid enough not to think of your solution. Need to leave office
    Cheers,
    Suhas

  • How to display the sort value in the selection screen in the report title

    Dear All,
    How to display the sort value in the selection screen in the report title? I have selected a value in the selection screen for sorting , but i need that values by which i have sorted with in the report title. Can you please throw some light on this!!
    Good day,
    Thanks and regards
    Arun S

    Hi Arun,
    Try this.
    1, Set one dynamic parameter,
    2, Drag and drop that parameter into  your report title.
    3, Pass the value(sort value) dynamically from your application,
    4, Cheers..
    Other wise Try with Dataset, create a dataset and fill thev alue into that.. Then  set the data source from CR designer. and darg and drop that data column into the report.
    Hope this will work,
    Regards,
    Salah
    Edited by: salahudheen muhammed on Mar 25, 2009 11:13 AM

  • Is there a way to obtain the text item's value when the mouse pointer at?

    Hi,
    Is there a way to obtain the text item's value when the mouse pointer at? Mouse pointer may be located somewhere out of current record and even out of current block.

    There is a when-mouse-over trigger and that works fine in client-server mode for Forms 5/6/6i, but that is less indicated when deployed using Application Server.
    In that trigger you may write whatever code is necessary, restricted package procedures.
    Still, I think, for your case, if you do not have to deal with a multi-record block, you should use the HINT property for that item and set_item_property with the HINT argument for that item in order to set the hint to the item's value - this should set_item_property should be called on the when-new-record-instance .

  • Retrieve input values from the selection screen

    I have a requirement to retrieve the variable value or values inputed from the selection screen and label the worksheet tab to replace the tab name 'Sheet1' from the Excel. The only way to do this would be to write a macro to label the sheets but how would I retrieve the value(s) from the selection screen criteria? Is the value of the selection screen entered by the user stored in some table? How would I write the macro to retrieve this value?
    For example, I want to retrieve the company code entered from the selection screen and lets say the company code entered as 10; I would want to replace the worksheet from 'Sheet1' to '10' . Texts would be more recognizable.

    Use the option Layout->Display Text Elements->Variables from the BEx toolbar. This will display Variable screen user input on your workbook in a fixed location. Then you can use your macro to name the worksheet with the cell reference.
    Thanks
    Vineet

  • Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

    hi all
    i have a table that name is:
    TiketsHeader 
    but i used this code
    SELECT TicketsHeaderId, Active, TH.PersonRef,P.Fname + ' ' + P.Lname AS NF, Serial, TicketsCnt, StartSerial, EndSerial, KindDate, StratDate, EndDate,
    MonthsRef1,(SELECT * FROM dbo.Months M WHERE M.MonthsId= MonthsRef1 ) AS MonthsName1 , MonthsRef2, MonthsRef3, WeekDaysRef,
    PoolTimesRef, TH.Descreption
    FROM dbo.TiketsHeader TH
    INNER JOIN Person P ON P.PersonId= TH.PersonRef
    i see this error:
    Msg 116, Level 16, State 1, Line 2
    Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
    how to solve it
    please help me
    Name of Allah, Most Gracious, Most Merciful and He created the human

    SELECT TicketsHeaderId, Active, TH.PersonRef,P.Fname + ' ' + P.Lname AS NF, Serial, TicketsCnt, StartSerial, EndSerial, KindDate, StratDate, EndDate,
    MonthsRef1,(SELECT * FROM dbo.Months M WHERE M.MonthsId= MonthsRef1 ) AS MonthsName1 , MonthsRef2, MonthsRef3, WeekDaysRef,
    PoolTimesRef, TH.Descreption
    FROM dbo.TiketsHeader TH
    INNER JOIN Person P ON P.PersonId= TH.PersonRef
    A Sub query like this can only return one column, not serveral like here with the star *. Replace the star by one column Name that you want to query.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Getting Tag and value from the selected Xml element value

    Hi All,
    I have an xml file which i import to the Indesign CS3 .From the structure view , i drag and drop the root node on to the page. Now i select an xml value from the page. Now i need to get the element tag and value from the selected value.
    For example
    File Name : sample1.xml
    <Root>
    <employeeName> A</employeeName>
    <employeeEmail>[email protected]</employeeEmail>
    </Root>
    Now i import this sample.xml in my indesign CS3 and from the structure view i drag the Root  tag and drop it on the page.Now the values of the element tag are displayed.
    Now i select "[email protected]" from the page and i have a menu "Get Selected XML" on clicking which  i should get element tag with value.(i.e <employeeEmail>[email protected]</employeeEmail>)
    How to go about it.?
    Thanks
    Sakthi

    Hi Steve,
    If you haven't already done so, I recommend posting this question in the LivCycle Forms forum.
    Jared

  • How to make the LV front panel controls the current value through the program is set as the default value when the next time you open?

    How to make the LV front panel controls the current value through the programis set as the default value when the next time you open?
    1110340051 

    Try this: Re: How to make a VI remember the latest control value?
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • Urgent: How to exclude a particular value from the selection in the infopac

    How to exclude a particular value from the selection in the infopackage.
    Ex: not load for cost center 10000
    Thank you,
    sam

    Hi Sam,
    You cannot do this directly as exclusion, but you can include all other values, even as ranges and thus exclude the particular value, else you can also try to do this by writing a routine.
    Hope this helps...

  • HT1551 hi i do not see hulu plus programs. I see the shows to select but when i select a show i see the circle spin then it say please try later. That has happened over the 2 days now. This is also now happening with Netflex.

    hi i do not see hulu plus programs. I see the shows to select but when i select a show i see the circle spin then it say please try later. That has happened over the 2 days now. This is also now happening with Netflex.

    its ok i just pulled the plug from the Apple TV waited 3 minutes and plugged back in and now it works.

  • Time when the waveform value cross a determined level

    Hi all,
    I'm using PCI-5112 with Labvew to capture a waveform and i'm getting a triangle form waveform type. How to find the time when the waveform value cross some predetermined values. To put it more clearly, I attached a picture. In my picture, I want to know TH (time interval when the Y value cross 100), TM ( time interval when the Y value cross 50), TL (time interval when the Y value cross 20). How to put these measurements through Labview program? Any clue or example would be very helpful. Thx  
    Attachments:
    description.jpg ‏22 KB

    You can do this using the built-in NI-SCOPE functions or the LabVIEW pulse waveform measurements VIs by tweaking the reference levels appropriately.  However, given the noise level in your signal, you may not be happy with the result, since these measurements are done essentially on a point-to-point basis.  A more robust option is to find the approximate location of the level crossing, take N points on either side of it, do a simple curve fit to this data, then use the curve fit to determine the actual level crossing.  A line fit would work on the first part of your curve, an exponetial or parabolic fit on the second.  A further optimization would be to use a robust fitting method, but it does not look like you need to go that far.
    If you need more details on any of these methods, let us know.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

Maybe you are looking for