Solved

Show second column only in combo box

Posted on 2006-06-09
8
441 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
  • 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 84
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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 84
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 84

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

808 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