ADO Tips & Tricks

1)     Connection Object

a)      Opening the Database

b)      Executing Commands

c)       Executing Queries

d)      Closing the Database

2)     Recordset Object

a)      The Fields Collection

b)      Editing Records

3)     Tools

a)      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 Example

a)      The SELECT Clause

b)      The WHERE Clause

c)       The Query

 

Download Example Programs

 

 

 

 

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