Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Combo Box Choice Populates Text Boxes

Discussion in 'Information Technology' started by Paperback Writer, Jul 28, 2006.

  1. Paperback Writer

    Paperback Writer
    Expand Collapse
    Guest

    I have a combo box that sits on a query. This query zeroes in on one field.
    I'd like about five other fields from this query to be populated based on
    which value is selected in the combo box.

    How do I do this?
     
  2. Loading...


  3. xRoachx

    xRoachx
    Expand Collapse
    Guest

    Hi PW -- Can you clarify a little? Do you mean the query is used to populate
    the combo box? Also, what do you mean by the query zeroes in on one field?
    Last, the five fields you want automatically populated, are these in a form
    or in the query?

    "Paperback Writer" wrote:

    > I have a combo box that sits on a query. This query zeroes in on one field.
    > I'd like about five other fields from this query to be populated based on
    > which value is selected in the combo box.
    >
    > How do I do this?
     
  4. Paperback Writer

    Paperback Writer
    Expand Collapse
    Guest

    When you set up a Combo Box, it asks if you want it to bring up values from a
    query or a table. I selected "query." I then asked it to only return one
    field, which is the pivotal field.

    The related fields are in the same query. I want those text boxes, all of
    which are inside a form, to populate depending on what is selected in the
    combo box.


    "xRoachx" wrote:

    > Hi PW -- Can you clarify a little? Do you mean the query is used to populate
    > the combo box? Also, what do you mean by the query zeroes in on one field?
    > Last, the five fields you want automatically populated, are these in a form
    > or in the query?
    >
    > "Paperback Writer" wrote:
    >
    > > I have a combo box that sits on a query. This query zeroes in on one field.
    > > I'd like about five other fields from this query to be populated based on
    > > which value is selected in the combo box.
    > >
    > > How do I do this?
     
  5. Ron2006

    Ron2006
    Expand Collapse
    Guest

    IF
    combo box query contains field1, field2 thru 5 in that seqence
    if forinstance only bound field shows and it is field 2 then the
    bound = 2
    number fields = 5
    field lengths = 0;1;0;0;0
    the above is what you are looking for in general.

    Now
    in the afterupdate event of the combo box you can retrieve the fields
    from that combo entry as follows

    me.txttoshow1 = me.comboboxname.column(0)
    me.txttoshow2 = me.comboboxname.column(1)
    me.txttoshow3 = me.comboboxname.column(2)
    me.txttoshow4 = me.comboboxname.column(3)
    me.txttoshow5 = me.comboboxname.column(4)

    The columns are relative to 0 (not 1)






    Paperback Writer wrote:
    > When you set up a Combo Box, it asks if you want it to bring up values from a
    > query or a table. I selected "query." I then asked it to only return one
    > field, which is the pivotal field.
    >
    > The related fields are in the same query. I want those text boxes, all of
    > which are inside a form, to populate depending on what is selected in the
    > combo box.
    >
    >
    > "xRoachx" wrote:
    >
    > > Hi PW -- Can you clarify a little? Do you mean the query is used to populate
    > > the combo box? Also, what do you mean by the query zeroes in on one field?
    > > Last, the five fields you want automatically populated, are these in a form
    > > or in the query?
    > >
    > > "Paperback Writer" wrote:
    > >
    > > > I have a combo box that sits on a query. This query zeroes in on one field.
    > > > I'd like about five other fields from this query to be populated based on
    > > > which value is selected in the combo box.
    > > >
    > > > How do I do this?
     
  6. xRoachx

    xRoachx
    Expand Collapse
    Guest

    In the AfterUpdate event of the Combo box, try the following:

    Forms!YourFormName.Filter = "YourQueryName.FieldName = " & """" &
    YourComboBoxName.Text & """"

    Watch out for word wrap! If you combo box is for numbers then it will look
    like this:

    Forms!YourFormName.Filter = "YourQueryName.FieldName = " &
    YourComboBoxName.Text

    I tested this on a form using an unbound combo box that was populated using
    a query.

    "Paperback Writer" wrote:

    > When you set up a Combo Box, it asks if you want it to bring up values from a
    > query or a table. I selected "query." I then asked it to only return one
    > field, which is the pivotal field.
    >
    > The related fields are in the same query. I want those text boxes, all of
    > which are inside a form, to populate depending on what is selected in the
    > combo box.
    >
    >
    > "xRoachx" wrote:
    >
    > > Hi PW -- Can you clarify a little? Do you mean the query is used to populate
    > > the combo box? Also, what do you mean by the query zeroes in on one field?
    > > Last, the five fields you want automatically populated, are these in a form
    > > or in the query?
    > >
    > > "Paperback Writer" wrote:
    > >
    > > > I have a combo box that sits on a query. This query zeroes in on one field.
    > > > I'd like about five other fields from this query to be populated based on
    > > > which value is selected in the combo box.
    > > >
    > > > How do I do this?
     
  7. Paperback Writer

    Paperback Writer
    Expand Collapse
    Guest

    I'm sorry, but I can't get either of these solutions to work. Please explain
    step-by-step.

    I put those commands in the combo box? Wouldn't I put them in the text box?
    This is prolly easy, and I'm totally missing it!

    What I want is something like this on my form. (bad attempt to follow at
    recreating the "look" of my form)


    |Combo Box Dropdown|

    |Text Box Data That Auto Populates Depending On Combo Choice|

    |Text Box Data That Auto Populates Depending On Combo Choice|

    |Text Box Data That Auto Populates Depending On Combo Choice|

    |Text Box Data That Auto Populates Depending On Combo Choice|
     
  8. xRoachx

    xRoachx
    Expand Collapse
    Guest

    Since your form is based on the query we need to do some work to display the
    values you want. To do this, you are going to use criteria, i.e., your combo
    box, to filter for the values you want.

    So in design view of your form, drag a combo box onto the form. In the
    wizard, select the query used to fill the combo box but do not select the
    option to store the value.

    Right click on the combo box and navigate to the Event tab. In the
    AfterUpdate event click the elipse (...) and choose Code Builder in the popup
    box to open the VBA editor. It is here you will place the code I gave you but
    you need to modify it to include your query and field names.

    "Paperback Writer" wrote:

    > I'm sorry, but I can't get either of these solutions to work. Please explain
    > step-by-step.
    >
    > I put those commands in the combo box? Wouldn't I put them in the text box?
    > This is prolly easy, and I'm totally missing it!
    >
    > What I want is something like this on my form. (bad attempt to follow at
    > recreating the "look" of my form)
    >
    >
    > |Combo Box Dropdown|
    >
    > |Text Box Data That Auto Populates Depending On Combo Choice|
    >
    > |Text Box Data That Auto Populates Depending On Combo Choice|
    >
    > |Text Box Data That Auto Populates Depending On Combo Choice|
    >
    > |Text Box Data That Auto Populates Depending On Combo Choice|
    >
     
  9. Paperback Writer

    Paperback Writer
    Expand Collapse
    Guest

    I know less than zero about VB.

    Where do I put this code?


    "xRoachx" wrote:

    > Since your form is based on the query we need to do some work to display the
    > values you want. To do this, you are going to use criteria, i.e., your combo
    > box, to filter for the values you want.
    >
    > So in design view of your form, drag a combo box onto the form. In the
    > wizard, select the query used to fill the combo box but do not select the
    > option to store the value.
    >
    > Right click on the combo box and navigate to the Event tab. In the
    > AfterUpdate event click the elipse (...) and choose Code Builder in the popup
    > box to open the VBA editor. It is here you will place the code I gave you but
    > you need to modify it to include your query and field names.
    >
    > "Paperback Writer" wrote:
    >
    > > I'm sorry, but I can't get either of these solutions to work. Please explain
    > > step-by-step.
    > >
    > > I put those commands in the combo box? Wouldn't I put them in the text box?
    > > This is prolly easy, and I'm totally missing it!
    > >
    > > What I want is something like this on my form. (bad attempt to follow at
    > > recreating the "look" of my form)
    > >
    > >
    > > |Combo Box Dropdown|
    > >
    > > |Text Box Data That Auto Populates Depending On Combo Choice|
    > >
    > > |Text Box Data That Auto Populates Depending On Combo Choice|
    > >
    > > |Text Box Data That Auto Populates Depending On Combo Choice|
    > >
    > > |Text Box Data That Auto Populates Depending On Combo Choice|
    > >
     
  10. Ron2006

    Ron2006
    Expand Collapse
    Guest

    For analysis of what is wrong we will need information more detailed
    that it didn't work.

    For my approach, I need the following information:

    For the Combobox what are the values in the following properties
    bound column = 2 from data tab
    column count = 5 from Format tab
    column widths = 0;1;0;0;0 from format Tab
     

Share This Page