Use string variable as RowSource for listbox

  • Thread starter Thread starter Mr. Smith
  • Start date Start date
M

Mr. Smith

Hi.

I try this as row source for a listbox

Dim sql as string

sql = "SELECT * FROM tblClients"

With myListbox
.RowSourceType = "Query/Table"
.RowSource = sql
End with

It does not work. Why?

This work:
With myListbox
.RowSourceType = "Query/Table"
.RowSource = "SELECT * FROM tblClients"
End with

Any contraints regarind variables as source for listboxes?

Mr. Smith
 
Most likely because sql is a reserved keyword! Try using another
parameter name instead; strSQL is quite commonly used.

HTH,
Nikos
 

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

Similar Threads


Back
Top