From: Philipp Post on
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: Daryl S on
Philipp -

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.

--
Daryl S


"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
Daryl,

>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.

brgds

Philipp Post
From: PieterLinden via AccessMonster.com on
Don't know if there's a better way... haven't gotten there yet, but this
works:

Option Compare Database
Option Explicit

Private Sub cmdRunQuery_Click()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(Me.txtSQLStatement, dbOpenForwardOnly)

With Me.List0
.RowSourceType = "Table/Query"
.RowSource = Me.txtSQLStatement
.ColumnHeads = True
.ColumnCount = rs.Fields.Count
.Requery
End With

rs.Close
Set rs = Nothing

End Sub

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
asked for...

--
Message posted via http://www.accessmonster.com