Viewing 2 columns in a Access 2003 combo box from a look up table

I want to display a 2 column look up table as a combo box in a form.  

I've created the table.

I've gone to the form and tried to add it as a combo box but can't get both columns to be visible.

What am I doing wrong?
Angelia1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rspahitzCommented:
Do you have it specified as a SQL query?  Are both fields in your select: SELECT field1, field2 FROM table...

And did you set the column width property with the appropriate widths? e.g. 1";1.5"
Rey Obrero (Capricorn1)Commented:
set the column count property of the combo box to 2
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
1. Click on the combo box and Go to Properties (F4).
2. Change Column Count to 2
3. Change Column Widths to (e.g.) 3cm;8cm
4. Go to Row Source, click on the ..., and ensure that there is more than 1 column visible in the Query Builder.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
5. Change Bound Column to whichever column you want bound.
6. If you want another text box to show the second column (once it has been clicked), change its Control Source to
=[myfield].[Column](1)

Where myfield is the name of your field, and (1) indicates the second column.
Angelia1Author Commented:
Thank you all for answering so quickly.  (sometimes my thought process isn't as clear as it is at other times so tell me if this sounds like the right path)

I have a table called physicians

I have a qry w these fields in it that I make all of my forms off of but, in this case i was going to use the tbl, physicians, directly as a look up table by making a combo box in my form.  This would list the physician their phone, fax and specialty (ie cardio, oncology and so on.)

I do have section in my db that Microsoft set up yrs ago using the same table where we choose the referring physician and it auto populates address phone/fax etc.  There are event proc attached to this.  Would it be better to try and recreate this scenario  by trying to follow what was done in the properties and copying the event procedures, changing the names of the records somehow to match specialist list now in place of a referring phy list as it was originally used?  Or should I stick w the combo box idea?

SideNote: I don't know how to write code or create event procedures. Doesn't mean I can't learn)   below is the event procedure as it is written for the referring phy box. (May be biting off more than I can chew but I thought I'd ask your advice first)

Private Sub cboMD_AfterUpdate()
Me.strRefMd = Me.cboMD.Column(2) & " " & Me.cboMD.Column(1)
Me.strRefMDAddress = Me.cboMD.Column(4) & " " & Me.cboMD.Column(5)
If Me.cboMD.Column(6) = "" Then
Else
Me.strRefMDCity = Me.cboMD.Column(6)
End If
If Me.cboMD.Column(7) = "" Then
Else
Me.strRefMDState = Me.cboMD.Column(7)
End If
If Me.cboMD.Column(8) = "" Then
Else
    Me.strRefMDZip = Me.cboMD.Column(8)
End If
If Me.cboMD.Column(9) = "" Then
Else
    Me.strRefMDPhone = Me.cboMD.Column(9)
End If
If Me.cboMD.Column(10) = "" Then
Else
    Me.stsrRefMDFax = Me.cboMD.Column(10)
End If
If Me.cboMD.Column(12) = "" Then
Else
Me.strMdType = Me.cboMD.Column(12)
End If
Me.strMDLName = Me.cboMD.Column(1)
Me.strRefMDID = Me.cboMD.Column(0)
Me.strMDFName = Me.cboMD.Column(2)
End Sub

Thanks
Rey Obrero (Capricorn1)Commented:
in the ddesign view of the form, select the combo box and hit F4
select the Event tab
look for the event  On Click
click the Down arrow and select [Event Procedure] and click on (...) to get to the VB editor
Angelia1Author Commented:
Ok, now what?
I'm at a box w 3 options
Expression Builder
Maco Builder
Code Builder
Angelia1Author Commented:
Right now the combo box I created is only showing the first name of the phy.  I chose multiple fields to be displayed but it only shows first name.
Rey Obrero (Capricorn1)Commented:
are you reading the suggestions?
Angelia1Author Commented:
I am and trying to follow them w my limited experience.
Angelia1Author Commented:
for example where does this go?   =[myfield].[Column](1)     If I put it in the event procedure section after clicking the (...) it gives me a compile error
Angelia1Author Commented:
What do I do after going to the VB Editor please?
Rey Obrero (Capricorn1)Commented:
sorry, you should look for the After update event, not On click

Private Sub cboMD_AfterUpdate()

'you will place here the codes that will be run/process when the after update event for 'the combo box is triggered

End Sub
PatHartmanCommented:
I created a sample database a few years ago that should explain how to do what you need to do.  One thing to keep in mind is that in a properly defined relational database, we do NOT duplicate data.  So for example, we don't keep the customer name in the order table.  We keep the CustomerID.  When we want to show the customer info on the order form, we use a query that joins tblOrder to tblCustomer and pull fields from both tables.
Picture of sample form showing three techniquesFillFormFields130127.zip
sharris_glascolCommented:
my problem is that I am updating fields into a table and when I select a different position then the other fields courses go away.  It is happening because of the after update on the position drop down.  Any idea on how to fix this?
PatHartmanCommented:
If you are using a continuous subform, this example will explain the problem and offer a solution.
FixCascadingCombos130128.zip
sharris_glascolCommented:
I am confused on changing the subform to a query.  will this not update the table.
sharris_glascolCommented:
I fixed it Instead of storing the ComboID I stored the Comboname
Angelia1Author Commented:
Hi, back to my original question.  How do I view more than one column on a form using a table as a look up in a combo box or is this the best solution to that?
Angelia1Author Commented:
I do not have experience in writing code or creating event procedures.  

Currently, even though I have several fields chosen only the MD's first name appears in the box on my form.  I want to be able to view the entire name as well as the phone and fax numbers
Angelia1Author Commented:
So by looking at what Pat has sent, the BEST case does not use code but could you be more specific on how that is set up please?  This looks like exactly what I need but I don't understand how to make it happen.
PatHartmanCommented:
If you just want to see multiple columns when the combo is closed, you have to concatenate them in the query.  Otherwise, once you select an item, you only see the first visible column.

Select EmpID, FirstName & " " & LastName as EmpName
From tblEmployee
Order by FirstName & " " & LastName;

EmpID is the bound column and it is what will be saved.  But by concatenating first and last names, you will see both in the control when the employee is selected.

To implement the BEST solution, you use a query that joins the main table to the lookup table.  For example, if you want to see the customer name and phone number on the order form, join tblOrder and tblCustomer and select columns from both tables.  Since the form is for entering an order, columns from tblCustomer that you bind to controls should have their locked property set to Yes because you don't want someone accidentally changing a customer name on the order since that will change the customer name in tblCustomer and so change the customer name for ALL orders.
Angelia1Author Commented:
Pat,
I am drawing the fields from a qry.  All the info does show up when I hit the drop down but when I close it it only shows the MDs first name.
PatHartmanCommented:
I know.  Please read my previous response again.  I told you how to concatenate multiple columns so you could see them all in the same box.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Angelia1Author Commented:
Ok, I take another look
Jim HornMicrosoft SQL Server Data DudeCommented:
Hey Angelia1 -  How's it going?  Looks like you've received multiple answers to your original question, so please consider closing this out by accepting the answer(s) that helped you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.