Solved

Show second column only in combo box

Posted on 2006-06-09
8
413 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

760 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

23 Experts available now in Live!

Get 1:1 Help Now