Column Heads in Listbox

M

Marcel Stoop

Hi

Is there a possibility to set the Column Heads for a Listbox manually,
something like "lstbox.ColumnHeads(x1,x2,x3)" for a List box with 3
collumns.

Through SQL I load some table rows in this Listbox, but I don't want to use
the standard Tableheads in the db (like fkcurrency), which get loaded when
setting the List Box Property Column Heads to "Yes".

Adding the SQL Statement with "SELECT fkcurrency As Currency, ........."
also is not optimal. In Acces this does not work.
The only thing that does work is: "SELECT fkcurrency As 'Currency',
.........." , but then the collumn Heads are presented between ' ':
'Currency'.

Regards
Marcel
 
A

Allen Browne

I doubt you can set the names of the column heads directly.
Using an alias in the SQL statement is the usual solution.
Currency is a reserved word in JET SQL, so not a good alias.

Another possibility might be to set the Caption property of the field in the
table. Access will use the Caption instead of the field name in the
ColumnHeads. Bit of a sledgehammer approach though, so I think I'd be more
likely to go with the alias. Could you live with Currencies instead of
Currency?
 
M

Marcel Stoop

Thanks for your Reply

Currencies is not the problem it was just an example.
The problem is: wenn I use the Alias in my SQL Statement I have to use the
Alias between ' ' ( "SELECT fkcurrency As 'Currencies') otherwise it won't
work.
But using ' ' will also represent the Column Head between ' '
 
A

Allen Browne

Strange. It works here without the quotes around the name:
SELECT Table1.fkCurrency AS Currencies FROM Table1;

Mind you, if you have Name AutoCorrect turned on, and you rename a field
alias, Access is likely to get confused. Turning off the "Name AutoCorrupt"
mis-feature might help. Details:
http://allenbrowne.com/bug-03.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top