Jump: Search:

Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access 2007/2010 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2010 (32 bit), 2007, 2003, 2002, 2000, and
Visual Basic 6.0!

Also available for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

 

 
Royalty free source code library modules for Microsoft Access, VB6, VBA, OfficeRoyalty free source code library modules for Microsoft Access, VB6, VBA, OfficeVBA and VB6 Source Code Library Download the free trial version of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA
Category: Microsoft Visual Basic 6 : Controls
Description: Code for working with VB6 controls

Module: modComboBox

Routines to extend the functionality of a standard VB ComboBox control.

Some of these procedures expose features which are inherent in the Windows control, but are not exposed by VB (such as the ability to set the drop-down list width). Other procedures add entirely new functionality such as loading a DAO recordset into an unbound combo box.

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the modComboBox module
AddItemDataComboBox Procedure Adds an item to a combo box, and the itemdata value associated with that item, in a single function call
ADORecordSetToComboBox Procedure Displays the contents of an ADO recordset in a standard unbound combo box. You are responsible for creating a recordset object in your code and passing it to this subroutine. You can create a recordset based on an entire table, or you can limit the values by using a query or a SQL statement. You may designate one field in the recordset to display in the list box, and another field to store in the ItemData property. Note that if you use a query to populate the combo box the display "field" can consist of a calculated expression, such as: SELECT LastName & ", " & FirstName AS FullName, CustID From Customers You could choose "FullName" as the display field and "CustID" as the key field to store in the ItemData property. Note that the value for the ItemData must be a storable in a Long Integer, so textual keys will not work.
BinarySearchComboBox Procedure Use a binary search to find a value in a combo box. A binary search works by dividing the values to be searched in half. If the search value is less than the value at the halfway point, then the top half is searched. If the value is greater than the value at the halfway point, then the bottom half is searched. This process is repeated until the value is either found, or no more values remain to be searched. This technique requires that the combobox be sorted.
DropComboBoxList Procedure Causes a combo box to show or hide the list portion. This function can be used to automatically drop down the list for a combo box when the user tabs into the combo box.
FindStringComboBox Procedure Finds the line on a combo box containing the search string. This function uses the Windows API SendMessage command to quickly find a string in a standard combo box control. You may search either for exact matches, or partial matches on the beginning of the combo box item. Note that case is not considered in doing the search, even if the fExact argument is true.
IncrementalSearchCombo Procedure Allows incremental searching of a combo box (on the KeyPress event of the ComboBox) As the user types in the text portion of a combo box, this code finds the first item in the combo that matches the value that the user has typed so far. If a value is found, the contents of the combo box text field is replaced. The portion of the text that the user did not type is selected so that it is immediately replaced as the user continues typing. This sub must be called from the KeyPress event of the combo box. Pass the KeyAscii argument of the KeyPress event directly through to the intKeyAscii argument. The style property of the ComboBox must be "0 - Dropdown Combo" for this to work
IsComboBoxDropped Procedure Determines if the list portion of a combo box is is currently visible
RecordSetToComboBox Procedure Displays the contents of a recordset in a standard unbound combo box. You are responsible for creating a recordset object in your code and passing it to this subroutine. You can create a recordset based on an entire table, or you can limit the values by using a query or a SQL statement. You may designate one field in the recordset to display in the list box, and another field to store in the ItemData property. Note that if you use a query to populate the combo box the display "field" can consist of a calculated expression, such as: SELECT LastName & ", " & FirstName AS FullName, CustID From Customers You could choose "FullName" as the display field and "CustID" as the key field to store in the ItemData property. Note that the value for the ItemData must be a storable in a Long Integer, so textual keys will not work.
SetComboBoxItemHeight Procedure Set the height of items in a combo box. VB normally uses the standard height for items in a listbox based on the type and size of the font in the list box. Using Windows API calls you can specify a different height.
SetComboBoxListItems Procedure Sets the number of items in the combo box list. This procedure lets you change the number of items that are displayed in the drop-down list portion of a combo box. Windows normally shows a default number of items. By changing this value you can designate the number of items that you want to appear. This might be useful if you have a combo box that displays the months of the year, for example, and you want to have twelve items displayed on the list. The number cannot be set to less than eight, or the actual number of items on the list, whichever is less.
SetComboBoxListWidth Procedure Set the width of the drop-down list portion of a combo box. Using the standard VB Combo Box control, the drop-down list portion of the combo box is always the same width as the combo box itself. Using this procedure you can specify that the list portion is wider than the actual combo box.

Overview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources

Feedback

Contact Us  l   Web questions: Webmaster   l   Copyright © FMS, Inc., Vienna, Virginia
Celebrating our 26th Year of Software Excellence