Solved

Show second column only in combo box

Posted on 2006-06-09
8
457 Views
Last Modified: 2010-07-16
I have a combo box that receives its rowsource from an update event in another combo box.  The sql that is passed to the combo box results in one record that has three fields of data.  I need the second field to be displayed.   The first field is an ID and I would like that to be hidden. The third field holds a value that I am passing to a text box so it does not need to be displayed.

I know that only one value can be shown at a time in a combo box unless the box is clicked.  What I want to have happen is for the second field to display without the user having to click the box at all.  

I am trying not to do this with a list box.  Is it possible?
0
Comment
Question by:johnnyloff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16875722
check out the property columnwidths for the combobox. set it to "0cm|5cm" for example to hide the first column
0
 

Author Comment

by:johnnyloff
ID: 16875746
AngelIII - That's how it was set.  What that does is show what seems to be a blank combo box.  After clicking on the combo box the record shows up as a one item list and needs to be clicked in order to show in the box.  

I need the record to show in the box as soon as the sql is passed to its rowsource.
0
 
LVL 85
ID: 16876823
You need to set the Value of the combo as well. If there is only one item in the list, you can do this:

Me.Combo2 = Me.Combo2.Column(0, 0)

which will select the first (and in your case the only) item.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:johnnyloff
ID: 16878009
LSMConsulting - That doesn't seem to change anything.  There is only one item in the list.  The value still needs to be clicked in order to display just as before.

All of this is on a pop-up.  My problems occur when a user is filling in the data for the first time.  If the pop-up is opened and bound to an existing record, then everything does, and always has, display correctly.  
0
 
LVL 85
ID: 16880378
Can you post the code you're using? The code I posted worked fine in my sample db ...
0
 

Author Comment

by:johnnyloff
ID: 16886566
I made a test simplified test version to make sure there weren't any problems in my actual database.  It performed the same.  This is the sql.

sql = " SELECT CONTRACT.CONTRACT_ID, CONTRACT.CONTRACT_CLIENT_ORG_ID, CONTRACT.CONTRACT_VARPROGRAM_ORG_ID "
sql = sql & " FROM CONTRACT "
sql = sql & " WHERE (((CONTRACT.CONTRACT_CLIENT_ORG_ID)=[Forms]![popRoyaltyReportingNew]![RPTG_CLIENT_ORG_ID]) AND ((CONTRACT.CONTRACT_VARPROGRAM_ORG_ID)=[Forms]![popRoyaltyReportingNew]![cboVarietyProgram])) ; "
 
Me!cboTerms.RowSource = sql
Me!cboTerms.Requery

This is in the on change event for cboVarietyProgram.  When the column widths are .5";.5" the correct ID shows up but not the second column.  When I try to hide the ID and just show the second column then it shows up as a blank field until it's clicked on and selected.
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 50 total points
ID: 16886673
When you say "popup", do you mean a form set to Popup=True? Or are you opening this some other way.

You don't need to .Requery - setting the rowsource does this automatically.

In my sampledb (posted here: www.infotrakker.com/downloads/db8.zip) this works fine ... perhaps you could look at this and see if it works for you.




0
 

Author Comment

by:johnnyloff
ID: 16887860
LSMConsulting - Thank you very much!  I do not know what I was doing wrong when I tried your code the first two times.  The solution was pretty simple but I was missing something.  I tried it again after looking at your sample db and it worked perfectly.  

Thank you for saving me a bunch of time.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question