Ethan Bradberry
Ethan Bradberry

Reputation: 107

Query reading criteria from a form

I have a query reading criteria from a dropdown form which is working ok.

It is checking for the program version.

i.e. V6,V7,V8 etc.

I would like to add an "ALL" option to the dropdown list so it can display all results. obviously there is no results for version "ALL". is this possible? if so how.

Upvotes: 0

Views: 36

Answers (1)

jhTuppeny
jhTuppeny

Reputation: 970

Yes this is possible. Use something like;

Dim sql As String, strVal As String
Dim rst As New ADODB.Recordset

sql = "SELECT ProgramVersion FROM Table ORDER BY ProgramVersion "
rst.Open sql, CurrentProject.Connection, adOpenStatic, adLockOptimistic

strVal = "All;"
With rst
    .MoveFirst
    Do Until .EOF
        strVal = strVal & Nz(!ProgramVersion, "") & ";"
        .MoveNext
    Loop
End With

MyCombo.RowSourceType = "Value List"
MyCombo.RowSource = strVal

Upvotes: 1

Related Questions