User Selected Fields from Form

V

Validlyte

Hello~

I am trying to create a form that would allow the user to select the fields
they would like in a query and then to execute the query. The number and
type of fields could be different each time executed. I was thinking that
the form could have checkboxes unbound that if checked would let the query
know to include the field represented by the checkbox or a listbox where
multiple selections could be made from a list of all the available fields.

I have seen some posts on the Choose option but that does not seem to work
for what I want in that there is not a set number of columns each time.

Any help would be greatly appreciated.

Mathew
 
V

Validlyte

Thanks for the tip ... For anyone looking I got this to work ... using check
boxes on a form with a command button to execute the sql below ... you also
need to create a blank query to send the sql to ...

Private Sub Command6_Click()
Dim strSQL As String
strSQL = "SELECT Events.ID "
If Me!Check0 = True Then
strSQL = strSQL & ", Events.Field1 "
End If
If Me!Check2 = True Then
strSQL = strSQL & ", Events.Field2 "
End If
If Me!Check4 = True Then
strSQL = strSQL & ", Events.Field3 "
End If
strSQL = strSQL & "FROM Events "
CurrentDb.QueryDefs("TempQuery").SQL = strSQL
DoCmd.OpenQuery "TempQuery"
End Sub
 
Top