We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Private Sub cmdRunQuery_Click() If Me.lstFieldList.ItemsSelected.Count = 0 Then MsgBox "Select some field names first." Exit Sub End If Dim qDef As Object Dim SQL As String Dim vItem As Variant ' loop through selected field names For Each vItem In Me.lstFieldList.ItemsSelected SQL = SQL & ",[" & Me.lstFieldList.ItemData(vItem) & "]" Next vItem ' build new SQL statement SQL = "Select " & Mid(SQL, 2) & " from [Employees]" ' save query with new SQL statement Set qDef = CurrentDb.QueryDefs("qryEmployees") qDef.SQL = SQL Set qDef = Nothing ' run query DoCmd.OpenQuery "qryEmployees" End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Datamismatch when doing a VBA Event in Access||6||39|
|VBA Code for Sending Form based on if there is information in the form only||15||35|
|"Function is not available in expressions in query expression" Error Message||4||27|
|MS Access Query Date Field Not Returning Results for the Correct Date||6||12|