Solved

VBA Combo Box will not release focus

Posted on 2009-05-18
3
394 Views
Last Modified: 2013-11-28
I am trying to set a combo box on an Access form to a value not present in the drop down list, which is empty. If I enter data, and try to set focus elsewhere on the form I am unable to do so - the empty drop-down box appears. If I delete all the entered data then I can move the focus away.  What do I have to do in order to set the value in the combo box?
0
Comment
Question by:SimonKravis
  • 2
3 Comments
 
LVL 84
ID: 24417690
If the dropdown is empty, you'd have to add the value to your combo's recordsource in order for it to display later. for example, if you have a combo, and you add the value "Bob" to it, Access will store that value in the combo's underlying field, but it will NOT store that value in the combo's underlying recordsource (i.e. whatever supplies the combo's RowSource). So if you navigate over to a different record, then back to the first record, then your combo won't show the stored value, since it won't be in combo's rowsource.
0
 

Author Comment

by:SimonKravis
ID: 24417911
Does a VBA combo box allow entry of values not in the dropdown list? A VB one does, but VBA controls are often subtly different. If it doesn't then what I want to do isn't possible.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 24421128
If you set the LimitToList property to No, Access will let you add anything you want in the combo. It will NOT, however, automatically add that to the Recordsource/RowSource of that control ... you must do that. The LimitToList and NotInList Event help topics explain this pretty thoroughly, with very good examples.
0

Featured Post

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.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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 different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

735 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