Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Show second column only in combo box

Posted on 2006-06-09
8
Medium Priority
?
469 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 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
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

877 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