				ComboBoxLB

Last changed at 03-july-2001.

Version 2.03



This control is created by Patrick van Olderen.
http://www.home.zonnet.nl/PatrickO/



Changes made:

============================================================

Bugs Fixed:

 - Showing the listbox did not work correctly when the combobox was placed on a MDI form.
   The listbox showed up behind the border of the main MDI form.

 - Filling the combobox from a SQL server resulted in one row in the combobox. 

 - Removed Value property from the Properties window.

 - If there is text in the textbox and the listbox is opened, the text
   is completely selected.

 - If text is typed in the textbox and a match is found and enter is pressed, the text
   is completely selected.

============================================================

Added:


Sub's:

============================================================

Public Sub ShowDropDown()

Opens the combobox and shows it's listbox part.

----------------

Public Sub FillComboBoxMultiColumnRecordset(ByVal rec As Variant)

Fills the combobox by passing a recordset
I've tested it with passing a DAO and an ADO recordset 

NOTE:
So now there are two ways of filling the combobox:
- Public Sub FillComboBoxMultiColumn(ByVal dbDatabase As Database, ByVal strSelectQuery As String)
- Public Sub FillComboBoxMultiColumnRecordset(ByVal rec As Variant)

============================================================



Example for SQL server connection:

Set the combobox to two columns.
Create a DSN (YOURDSNNAME) which points to your SQL database (DATABASENAME).
Change sa and password in the code in an user which has enough rights to read the table.

Private Sub cmdConnect_Click()
   
   Dim wrkJet As Workspace
   Dim dbSQL As Database
   
   Set wrkJet = DBEngine.CreateWorkspace("ODBCWorkspace", "Admin", "", dbUseODBC)    ' create workspace
   Set dbSQL = wrkJet.OpenConnection("NoNeedToChange", dbDriverNoPrompt, False, "ODBC;DATABASE=DATABASENAME;DSN=YOURDSNNAME;UID=sa;PWD=password;")    ' get connection to database
   
   strSQL = "SELECT DISTINCT field1, field2 FROM TABLE WHERE TABLE.field1 Is Not Null ORDER BY field1"
   ComboBoxLB1.ColumnWidths = "750;750"
   ComboBoxLB1.FillComboBoxMultiColumn dbSQL, strSQL

End Sub






This control is created by Patrick van Olderen.
http://www.home.zonnet.nl/PatrickO/



Using this control is for your own risk. I do not take any responsibility for harm done using this control.