Solved

Show second column only in combo box

Posted on 2006-06-09
8
423 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 142

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
 

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

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now