Combo box activate a listbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ElTipo
    New Member
    • Jul 2007
    • 36

    Combo box activate a listbox

    Hi Gente,

    I need to Know how I can activate a list box value with combo box after update function. example I have a combo box if i chosse any in list from combo box then activate a list box "like on_click" selecting the last autonumber ID in this list box.

    ¿How? Masters!

    Thanks for any Ans.... Gracias!!!
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    I'm not sure from your question exactly what you are doing but have a look at this tutorial and see if it helps.

    Comment

    • ElTipo
      New Member
      • Jul 2007
      • 36

      #3
      Originally posted by mmccarthy
      I'm not sure from your question exactly what you are doing but have a look at this tutorial and see if it helps.
      Thanks for your Answer but its not a Cascading Combo box Im not sure.

      OK, If I select a value in combo box then go to my list box and select the last autonumber record. Like activate the function for my list box and Automatic chose the last record in list box.

      Comment

      • Scott Price
        Recognized Expert Top Contributor
        • Jul 2007
        • 1384

        #4
        Your questions aren't clear enough at this point to be able to help out.

        If you would be more comfortable in spanish, I can try to help out with your question, or if I can't answer it I can translate so one of the experts CAN answer it.

        What is the name of your combo box, what is the name of the list box, and what is the data represented in each?

        Regards,
        Scott

        Comment

        • ElTipo
          New Member
          • Jul 2007
          • 36

          #5
          Originally posted by Scott Price
          Your questions aren't clear enough at this point to be able to help out.

          If you would be more comfortable in spanish, I can try to help out with your question, or if I can't answer it I can translate so one of the experts CAN answer it.

          What is the name of your combo box, what is the name of the list box, and what is the data represented in each?

          Regards,
          Scott
          Hi Scott

          My Combo box is cbobranch and my list box is lstRates I need to select any branch in my cbobranch then my list box lstRate select automatic the recently Rate in table. The user only click any value in cbobranch and the lstRate choose the the ultimate rate entry.

          Hola Scott
          Mi combo box es cbobranch y mi list box es ldtRates cuando seleccione una sucursal en mi combo box automaticamente se activa el list box lstRates. El usuario no necesita hacer click en el lstRates.


          Sorry for my english.

          Thanks for your time.

          Comment

          • Scott Price
            Recognized Expert Top Contributor
            • Jul 2007
            • 1384

            #6
            De nada por cualquier ayuda que puedo ofrecerle...

            ¿Qué es la estructura de su forma? ¿Es basada en un 'query', o en un 'table'?
            ¿En su combobox, es cada branch associada con solo un valor en su listbox?
            ¿Qué es la estructura de su combobox y listbox? Por ejemplo, para hacer funcionar lo que está tratando de hacer, tiene que tener 2 columnas en cada control, la primera columna debe ser el numero de identificación. La primera columna puede tener una anchura de 0" para que no pueda verla.

            A mi parecer, no tiene que usar un 'listbox' por lo que está tratando de hacer, un 'textbox' sería suficiente.

            Mis pensamientos en este momento, sin saber las respuestas de mis preguntas arriba, es que tiene que basar su forma en un query que jala los valores necisarios. En su query, en el campo 'criteria' debajo de su campo Rates, entre este: Forms![NombreDeSuForma].cboBranch

            Su combo box no tiene que ser 'bound' (pegada) a ningun campo en su query, pero el textbox o listbox si, tiene que ser pegada al campo Rates de su query. Suficiente para su combo box tener en el 'Row Source', algo semejante a:
            Code:
            Select BranchID, Branch From tblBranch
            Despues, entre este codigo en el evento "AfterUpdat e" de su cboBranch: (en ingles :-)

            Code:
            Me.Requery
            Y, su ingles está bien...

            Ojalá que este sea de ayuda...

            Regards,
            Scott

            Comment

            • Scott Price
              Recognized Expert Top Contributor
              • Jul 2007
              • 1384

              #7
              I will happily translate this post into English to avoid running afoul of the general posting guidelines, as well as to be helpful to anyone else who is browsing this forum!

              The general reply I gave is:

              What is the structure of your form? Is it based on a query or a table? In your combo box, is each branch associated with only one value in your listbox? What is the structure of your combobox and listbox? For example, to make what you are trying to do work, you need to have two columns in each control, the first column should be the ID number field, and only needs to have a width of 0", so you don't have to see the numerical value in it.

              I don't think you need to use a listbox for what you are trying to do, a textbox should be enough.

              My thoughts at this moment, without knowing the answers to my questions above, is that you need to base your form on a query that pulls the needed values. In your query, in the criteria field below your Rates field, enter this: Forms![YourFormName].cboBranch...

              Your combobox can be unbound, but your text/listbox needs to be bound to the Rates field of your query. It should be enough for your combo box to have it's Row Source setting something like this:
              Code:
              Select BranchID, Branch From tblBranch
              Then, enter this code in the AfterUpdate event of your cboBranch:

              Code:
              Me.Requery
              Scott

              Comment

              • Scott Price
                Recognized Expert Top Contributor
                • Jul 2007
                • 1384

                #8
                Disculpe,
                Code:
                Forms![NombreDeSuForma].cboBranch
                tiene que estar en el campo criteria debajo de BranchID en su query.

                Excuse me,
                Code:
                Forms![YourFormName].cboBranch
                needs to go in the criteria field under your BranchID field in your query.


                Regards,
                Scott

                Comment

                • ElTipo
                  New Member
                  • Jul 2007
                  • 36

                  #9
                  Originally posted by Scott Price
                  Disculpe,
                  Code:
                  Forms![NombreDeSuForma].cboBranch
                  tiene que estar en el campo criteria debajo de BranchID en su query.

                  Excuse me,
                  Code:
                  Forms![YourFormName].cboBranch
                  needs to go in the criteria field under your BranchID field in your query.


                  Regards,
                  Scott
                  Hi Scott, Thanks for your time, my answers is under line for your Q?

                  Q. What is the structure of your form?
                  - Is a single form
                  Q. Is it based on a query or a table?
                  - Is based on a query, include tblbranch, tblEmployees, tblRates & the many table tblCharges. The branch & Employee tables are related with tblCharges. but the tblRate is not related.
                  Q. In your combo box, is each branch associated with only one value in your listbox?
                  - The combo box it obtains the info. for tblbranch. The combo box have branchID & list the name of branches 2 columns. The branchID is related with branchID field in the many tblCharges. if I choose the first name branch then the branchID resgistered in the many tblCharges.
                  - My list box have 7 columns RateID its included in the 7 but the user no see this field. Only see the numbers of fields rates ex. 10, 0.08 etc..and the field date for any change in the rate.

                  I put the criteria in a query - Forms![YourFormName].cboBranch under branchID
                  and Me.Requery afterupdt in cbobranch. But not function. My list box can't activate. My combo box after updt can't select in the list box the last rate that user entry.

                  Any other info. for your great help as need ask me...

                  Thanks Again

                  Comment

                  • Scott Price
                    Recognized Expert Top Contributor
                    • Jul 2007
                    • 1384

                    #10
                    Originally posted by ElTipo
                    Hi Scott, Thanks for your time, my answers is under line for your Q?

                    Q. What is the structure of your form?
                    - Is a single form
                    Q. Is it based on a query or a table?
                    - Is based on a query, include tblbranch, tblEmployees, tblRates & the many table tblCharges. The branch & Employee tables are related with tblCharges. but the tblRate is not related.
                    Q. In your combo box, is each branch associated with only one value in your listbox?
                    - The combo box it obtains the info. for tblbranch. The combo box have branchID & list the name of branches 2 columns. The branchID is related with branchID field in the many tblCharges. if I choose the first name branch then the branchID resgistered in the many tblCharges.
                    - My list box have 7 columns RateID its included in the 7 but the user no see this field. Only see the numbers of fields rates ex. 10, 0.08 etc..and the field date for any change in the rate.

                    I put the criteria in a query - Forms![YourFormName].cboBranch under branchID
                    and Me.Requery afterupdt in cbobranch. But not function. My list box can't activate. My combo box after updt can't select in the list box the last rate that user entry.

                    Any other info. for your great help as need ask me...

                    Thanks Again
                    1. Does each branch have a particular rate associated?

                    2. Or are you trying to simply have a rate display in the list box according to the latest dated rate?

                    If #1, then in order to have your cboBranch affect your list box Rates, you will have to relate the two tables in your query in some way.

                    Please post the sql code behind this query... (go into query design view, right click on the top of the query window, choose sql view, and copy/paste to a reply here.)

                    Where does your listbox get its data from? Is it from a separate query, or is it pulling from the same query as your main form?

                    If #2, I'll need to know more about your listbox, such as it's row source property, etc...

                    You're doing quite well in English so we continue without the Spanish for the moment... If needed we can switch :-)

                    Regards,
                    Scott

                    Comment

                    • ElTipo
                      New Member
                      • Jul 2007
                      • 36

                      #11
                      Originally posted by Scott Price
                      1. Does each branch have a particular rate associated?

                      2. Or are you trying to simply have a rate display in the list box according to the latest dated rate?

                      If #1, then in order to have your cboBranch affect your list box Rates, you will have to relate the two tables in your query in some way.

                      Please post the sql code behind this query... (go into query design view, right click on the top of the query window, choose sql view, and copy/paste to a reply here.)

                      Where does your listbox get its data from? Is it from a separate query, or is it pulling from the same query as your main form?

                      If #2, I'll need to know more about your listbox, such as it's row source property, etc...

                      You're doing quite well in English so we continue without the Spanish for the moment... If needed we can switch :-)

                      Regards,
                      Scott
                      Yea number 2, the first field in the list box like "column" is DateChangeRt. Its better for the user to know what is the correct rate for any branch to choose.

                      Only display rates but the user select the correct for any branch right now. I desire to avoid that the user select rate is not exiting any change for any branch.

                      My cbobranch is:

                      SELECT tblBranch.Branc hID, tblBranch.Branc hName FROM tblBranch ORDER BY tblBranch.Branc hName;

                      My lstRate is:

                      SELECT tblRate.RateID, tblRate.DateCha ngeRt, tblRate.Nofixed Rt, tblRate.Quantit yRt, tblRate.SchgRqt Rt, tblRate.SchgSpe RqtRt, tblRate.SchgSaR t FROM tblRate;

                      thanks scott

                      Comment

                      • Scott Price
                        Recognized Expert Top Contributor
                        • Jul 2007
                        • 1384

                        #12
                        You didn't specifiy, but assuming that your list box is based on this query in it's Row Source field

                        SELECT tblRate.RateID, tblRate.DateCha ngeRt, tblRate.Nofixed Rt, tblRate.Quantit yRt, tblRate.SchgRqt Rt, tblRate.SchgSpe RqtRt, tblRate.SchgSaR t FROM tblRate;
                        To show ONLY the latest changed record, you can change it to this:

                        SELECT tblRate.RateID, tblRate.DateCha ngeRt, tblRate.Nofixed Rt, tblRate.Quantit yRt, tblRate.SchgRqt Rt, tblRate.SchgSpe RqtRt, tblRate.SchgSaR t FROM tblRate WHERE tblRate.DateCha ngeRt = DMax ("[DateChangeRt]", "tblRate");

                        This will return only one row in your list box, the row with the latest date...

                        Not sure if this is really what you are looking for, but it is actually the most efficient way of displaying the data you are asking for (as I understand your request).

                        Regards,
                        Scott

                        Comment

                        • ElTipo
                          New Member
                          • Jul 2007
                          • 36

                          #13
                          Originally posted by Scott Price
                          You didn't specifiy, but assuming that your list box is based on this query in it's Row Source field



                          To show ONLY the latest changed record, you can change it to this:

                          SELECT tblRate.RateID, tblRate.DateCha ngeRt, tblRate.Nofixed Rt, tblRate.Quantit yRt, tblRate.SchgRqt Rt, tblRate.SchgSpe RqtRt, tblRate.SchgSaR t FROM tblRate WHERE tblRate.DateCha ngeRt = DMax ("[DateChangeRt]", "tblRate");

                          This will return only one row in your list box, the row with the latest date...

                          Not sure if this is really what you are looking for, but it is actually the most efficient way of displaying the data you are asking for (as I understand your request).

                          Regards,
                          Scott
                          Hi Scott,

                          The instruction code its work in the list box but for I need no.

                          I need that the "listbox" activate for "Default" the last one "Record" but that the user have option to choose some previous. When the "Combo box" be selected be activated the "list box" like "on click" function. The "list box" is not still selected. The "list box" it should activate after update in combo box.

                          Necesito que el "list box" active su función en el "record" más reciente pero que el usuario no tenga que hacerlo "On Click". Este debe activarse luego de seleccionar el "Combo box".

                          Thanks for your time....

                          Comment

                          • Scott Price
                            Recognized Expert Top Contributor
                            • Jul 2007
                            • 1384

                            #14
                            Originally posted by ElTipo
                            Hi Scott,

                            The instruction code its work in the list box but for I need no.

                            I need that the "listbox" activate for "Default" the last one "Record" but that the user have option to choose some previous. When the "Combo box" be selected be activated the "list box" like "on click" function. The "list box" is not still selected. The "list box" it should activate after update in combo box.

                            Necesito que el "list box" active su función en el "record" más reciente pero que el usuario no tenga que hacerlo "On Click". Este debe activarse luego de seleccionar el "Combo box".

                            Thanks for your time....

                            In the AfterUpdate event of your combo box, set the focus to your list box with this line of code: [CODE=vb]Me![YourListBoxName].SetFocus[/CODE]

                            In the GotFocus event of your listbox you will need to do a recordset/bookmark. You can try writing the code yourself, looking in MS Access help file for the syntax. I've got a snippet of code I'm working on at the moment, but won't post it yet because it's not behaving correctly in my test db... I only mention this for reference purposes, and so you can get a jumpstart on understanding the concept of what we're trying to do.

                            [Added Idea] You can, as another idea, change the RowSource of the list box to this:
                            Code:
                            SELECT tblRate.RateID, tblRate.DateChangeRt, tblRate.NofixedRt, tblRate.QuantityRt, tblRate.SchgRqtRt, tblRate.SchgSpeRqtRt, tblRate.SchgSaRt FROM tblRate; ORDER BY tblDate.DateChangeRt DESC;
                            This will place the latest dated record as the first record listed in your listbox.

                            Back Soon!
                            Regards,
                            Scott
                            Last edited by Scott Price; Aug 8 '07, 01:44 PM. Reason: Added Idea

                            Comment

                            • Scott Price
                              Recognized Expert Top Contributor
                              • Jul 2007
                              • 1384

                              #15
                              If instead of ordering the list box by descending date, as in my previous post have a look at this thread, where I got help from JKing to debug the select record in listbox function...



                              Regards,
                              Scott

                              p.s. please post back to let us know if you've got it working!
                              Last edited by JKing; Aug 8 '07, 03:22 PM. Reason: Added hyperlink

                              Comment

                              Working...