Solved

Autoselecting the First item in a combo-box

Posted on 1998-08-05
5
146 Views
Last Modified: 2010-04-30
I am sure this has been answered before, but I don't feel like searching through 5000 questions.  How do you autoselect the first item in a drop-down combo box.  I have added all of the items in there, but I want the first item to be pre-selected.
0
Comment
Question by:dt19643063098
  • 3
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 50 total points
Comment Utility
Combo1.ListIndex = 0
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
Now that I've locked in the answer, to avoid errors in case the list is empty, you should use this code:
If Combo1.ListCount > 0 Then
  Combo1.ListIndex = 0
Else
  Combo1.ListIndex = -1
End If
0
 

Author Comment

by:dt19643063098
Comment Utility
That doesn't allow me to select anything, it autoselects it and then invokes the click event.  I mis-worded the question.  I want the first item to appear, but not be pre-selected.
0
 
LVL 6

Expert Comment

by:clifABB
Comment Utility
Oh, in that case:
Combo1.Text = Combo1.List(0)
(use the error avoiding code above)

0
 

Author Comment

by:dt19643063098
Comment Utility
Thanks for the help.  If your familiar with Crystal Reports, you might want to look at the other question I submitted.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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

10 Experts available now in Live!

Get 1:1 Help Now