ADO Tips & Tricks1) Connection Objecta)
Opening the Database
b)
Executing Commands
c)
Executing Queries
d)
Closing the Database
2) Recordset Objecta)
The Fields Collection
b)
Editing Records
3) Toolsa)
One Column Queries
b)
ComboBox Example
c)
One Row Queries
d)
Multi-Column Queries
e)
Getting Field Names
f)
ComboBox Example, 2
4) A Useful Examplea)
The SELECT Clause
b)
The WHERE Clause
c)
The Query
|
ComboBox
Example, 2
Using
the GetQueryFields
function, it is easy to initialize a ComboBox using the results returned by a
query.
Public Sub InitializeComboFromQueryFields(
_
ByVal cbo As ComboBox, _
ByVal query As String, _
Optional ByVal allow_blank As Boolean = False)
Dim results As Collection
Dim i As Integer
' Execute the query.
Set results = GetQueryFields(query)
' If we should allow blanks, start with a blank.
cbo.Clear
If allow_blank Then cbo.AddItem ""
' Initialize the ComboBox.
For i = 1 To results.Count
cbo.AddItem results(i)
Next i
End Sub
|