Adding fields to Text Boxes from a querry in the form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've have a form with a combo box set up with a querry to place more
information into text boxes. These text boxes are not used for the user to
tab to to place data in but for the data to be already there when they select
a name in the combo box. But how do I get that infomation to show up into
the text boxes?

Thanks

Donna
 
Let's assume the following:
Your combo box name is cboNames--its rowsource has 4 columns, let's call
them Name, Street, City, State and is bound to column 1 (the Name field) and
column widths are 1",0",0",0" so that only the name shows up in the
drop-down list. You have three text boxes to show the additional info;
txtStreet, txtCity, txtState--they are locked and disabled (so the user
can't get into them. Since referring to a combo box's columns starts
counting at zero, the control source for each text box would be what's
inside the quotes in the following:
txtStreet: "=cboNames.Column(1)"
txtCity: "=cboNames.Column(2)"
txtState: "=cboNames.Column(3)"
 
This is what I'm looking for. Except where in the Properties box do I insert
the columns that you mentioned?

Donna
 
Are you talking about the combo box? If so, the columns are created by the
query you use as the combo box's row source. If your query has 4 fields in
it, your combo box will have 4 columns. On the Format tab of the Properties
window, you'll find "Column Count" and "Column Widths". You can even decide
how many rows to show in the drop-down list by changing the "List Rows"
value from the default of 8.
 
OK - Maybe I'm not say this right.

I see the for columns in the combo box. That's great but how do I get that
information into separate text boxes on the form? Do I do something within
the properties box for each text box? Actually, I have the first text box
showing the correct data but the other 3 are blank but in the combo box it
shows that there is data that needs to go into those fields.

Donna
 
Ah, I see.
For each text box, in the Properties sheet, the "Control Source" should be
set for the column of the combo box that holds the information you want to
display. So if textbox1 is supposed to display the address info which is
stored in the second column of the combo box (remembering that the columns
start at zero), the control source of textbox1 should be
"=cboName.Column(1)" without the quotes. The control source for the next
text box will be "=cboName.Column(2)", etc. Of course, "cboName" should be
replaced with the actual name of your combo box, which should not be named
the same as the field it's bound to.
 
Thanks Mark. This is what I needed to know.

Mark said:
Ah, I see.
For each text box, in the Properties sheet, the "Control Source" should be
set for the column of the combo box that holds the information you want to
display. So if textbox1 is supposed to display the address info which is
stored in the second column of the combo box (remembering that the columns
start at zero), the control source of textbox1 should be
"=cboName.Column(1)" without the quotes. The control source for the next
text box will be "=cboName.Column(2)", etc. Of course, "cboName" should be
replaced with the actual name of your combo box, which should not be named
the same as the field it's bound to.
 
Back
Top