By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

Display two columns in Access

P: 7
Hello,

I'm working on a form in Access 2007, and specifically on a combo-box field that displays two columns in the drop-down menu. The problem is that once I make a selection, the field only displays one of the two columns in the filled out box (the column on the left). I'd like to have both columns displayed after making a selection. Does anyone how I can achieve that? Thanks in advance.

John
Apr 28 '10 #1
Share this Question
Share on Google+
5 Replies


patjones
Expert 100+
P: 931
Hi,

Combo boxes display a single value after selection. But, I was able to do what you are suggesting by putting this in for the After Update event of the combo box:

Expand|Select|Wrap|Line Numbers
  1. Me.cbo.Value = Me.cbo.Column(0) & "     " & Me.cbo.Column(1)

The obvious drawback here is that the combo box's actual value will now be whatever the combined columns are, and this is not a good way to design it. If you feel like you must display more than whatever the bound column is, I would drop a text box in next to the combo box and do it there, so as to keep the combo box single-valued.

Pat
Apr 28 '10 #2

P: 7
@zepphead80
Hey Pat,

Thanks for your response. I did what you suggested (I think), but I received the following message when I then tried to make a selection from the combo-box:

Microsoft Access can't find the object 'Me.'
If 'Me' is a new macro or macro group, make sure you have saved it and that you have typed its name correctly.

I must admit that I know relatively little about Access, so I have no idea what this message is asking me to do. Any idea how to make it read that code correctly? Thanks again.

John
Apr 29 '10 #3

patjones
Expert 100+
P: 931
Hi,

Can you post all the code you have so far?

"Me" is just a shorthand way of saying whatever your current database object is (form, report, etc.) When you type "Me.", a list should pop up with various commands you can use in relation to the form, and also all the controls on the form. Also bear in mind that when I wrote "Me.cbo.Value", I was implying that you should replace "cbo" with whatever the name of your combo box is.

Pat
Apr 29 '10 #4

P: 7
Hey Pat,

Here's the code that I have right now:

Private sub Facility_AfterUpdate()
AfterUpdate.Facility.Value = AfterUpdate.FacilityID.Column(0) & " " & AfterUpdate.FacilityName.Column(1)
End Sub

So the field name for the whole combobox is "Facility," the column on the left is "FacilityID," and the column on the right is "FacilityName."

Also, the two dropdown boxes at the top of the Visual Basic code window are set to "Facility" and "AfterUpdate," if that helps. Thanks again.

John
Apr 29 '10 #5

missinglinq
Expert 2.5K+
P: 3,532
These lines

Expand|Select|Wrap|Line Numbers
  1. AfterUpdate.Facility.Value = AfterUpdate.FacilityID.Column(0) & " " & AfterUpdate.FacilityName.Column(1)
  2.  
need to be

Expand|Select|Wrap|Line Numbers
  1. Me.Facility.Value = Me.FacilityID.Column(0) & " " & Me.FacilityName.Column(1)
Linq ;0)>
Apr 29 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.