From: Philipp Post on 2 Feb 2010 10:37
I would like to display the results of a SELECT statement which the
user enters into a textbox dynamically in a listbox, but the first
column is always omited in the results
The forms code is like this:
If SQL_Statement Like "SELECT*" Then
Me.Results_Listbox.ColumnHeads = True
Me.Results_Listbox.ColumnCount = 255
Me.Results_Listbox.RowSource = SQL_Statement
How could this be fixed? Is there propably a better control for this?
Thanks n brgds
From: Daryl S on 2 Feb 2010 15:00
Look at the column widths for your listbox. I'll bet the first column is
set to 0". Give all the columns a width and see if that fixes it.
"Philipp Post" wrote:
> Good day,
> I would like to display the results of a SELECT statement which the
> user enters into a textbox dynamically in a listbox, but the first
> column is always omited in the results
> The forms code is like this:
> If SQL_Statement Like "SELECT*" Then
> Me.Results_Listbox.ColumnHeads = True
> Me.Results_Listbox.ColumnCount = 255
> Me.Results_Listbox.RowSource = SQL_Statement
> End If
> How could this be fixed? Is there propably a better control for this?
> Thanks n brgds
> Philipp Post
From: Philipp Post on 3 Feb 2010 04:04
>Give all the columns a width and see if that fixes it.<
Thanks, that was it. I overlooked to assign that property in the code.
From: PieterLinden via AccessMonster.com on 6 Feb 2010 23:45
Don't know if there's a better way... haven't gotten there yet, but this
Option Compare Database
Private Sub cmdRunQuery_Click()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(Me.txtSQLStatement, dbOpenForwardOnly)
.RowSourceType = "Table/Query"
.RowSource = Me.txtSQLStatement
.ColumnHeads = True
.ColumnCount = rs.Fields.Count
Set rs = Nothing
Don't know any other way to get the count of columns/fields in the result
without opening a recordset based on it... but I always get all the Fields I
Message posted via http://www.accessmonster.com
Prev: Incremental Numbering
Next: When I set the Orderby to true on my form access crashes by why?