combo box

F

faezah

how to make other data in text box appear when entering information in list
box..
for example..my database have a combobox of company name..and when i choose
one of the company name, i want the detail about the company is automatically
displaying like no fax and email

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...3ed7135fff0e&dg=microsoft.public.access.forms
 
G

Graham Mandeno

Hi Faezah

A combo box can have many columns. The only column that is visible when the
box is not dropped down is the first one with non-zero width. However, the
other columns are available via the Column property.

For example, say you have a combo box with these properties:
Name: cboCustomer
ColumnCount: 4
BoundColumn: 1
ColumnWidths: 0cm; ;0cm; 0cm
(notice the width of the second column is blank, so it will use all the
available space)
RowSource: Select CustID, CustName, CustFax, CustEmail
from Customers order by CustName ;

Now, the CustFax and CustEmail columns are in the combo box but they are
hidden (width=0).

You can now place two textboxes on your form:
Name: txtCustFax
ControlSource: cboCustomer.Column(2)
and
Name: txtCustEmail
ControlSource: cboCustomer.Column(3)

These will display those fields for the currently selected customer.

Note that the column number starts counting from zero. Column(2) is the
third column.
 
J

Jim Bunton

Set the form's recordsource to something like

SELECT * FROM myTableOrQuery
WHERE Companyname = [Forms]![ThisformName]![MyUnBoundComboName]

put the combo (NOTE it must be unbound) in the form header section and make
it's rowsource something like

SELECT CompanyName FROM MyTableOrQuery
ORDER BY CompanyName

make the combo OnClick event something like

Private Sub FindCompany_Click()
me.requery
end sub


when the form opens no records are displayed because the combo is blank
when it is clicked the record for the selected company is displayed

NOTE - you MAY have duplicate company names!!! in which case use the
companyId (unique!!!) as the where clause criterion. Make the Combo
rowsource something like

SELECT CompanyId, CompanyName & " - " & Town AS CompanyNameAndTown FROM
MyTableOrQuery
ORDER BY CompanyName, Town

Then look at the column widths property of the Combo and make the first one
0. Your user will just see the CompanyNameAndTown.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top