Hello!
I have some code here to run dynamic SQL code from a text box that user types into. It runs fine and returns the recordset for viewing in the listbox lstResult. However, it only returns the first column of the results. I know I need a .ColumnCount = something property, but I don't know how to go about actually counting them! Please help!
Private Sub cmdrunquery_Click()
Dim dbsMenuStudy As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set dbsMenuStudy = Currentdb
strSQL = Me.txtSQL
Set rs = dbsMenuStudy.OpenRecordset(strSQL)
With Me.lstResult
Set rs = dbsMenuStudy.OpenRecordset(strSQL)
If rs.RecordCount > 0 Then
.RowSourceType = "Table/Query"
.RowSource = strSQL
.Enabled = True
'display * fields
.ColumnCount =
.ColumnHeads = True
Else
.ColumnCount = 1
.RowSourceType = "Value List"
.RowSource = "No records found."
End If
End With
End Sub