By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,476 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,476 IT Pros & Developers. It's quick & easy.

Syntax errors with a listbox (rowsource)

P: n/a
I have 3 problems which I'd like people to solve for me (I've run out
of ideas)
1)

I have a table called s7-300. If i simply run this line of code:
lstResult.rowsource = "Select * FROM S7-300"

I will get a syntax error. So i have to rename my table. Is it
possible to leave the
table name alone and format that line of code so that it will work?
2)

My table "s7300" was imported from an excel datasheet. As such the
field numbers are
1,2,3,4,5 ect.

If i try a simple line of code as follows:

Lstresult.rowsource = "Select 1 FROM S7300"

As a result, i need to rename each of the fields manually. I would
like to be able
to accept data whilst they are named numerically.
3)

This time I change the rowsourcetype to Value List.

I run this line of code:

lstresult.rowsource = "Title1;title2;" & blah.column(0,blah.listindex)
& ";" & blah.column(1,blah.listindex) & ";"

If any of the queried items has a comma "," in it, the listbox assumes
this means it is a new entry.
This results in the data not being formatted the way i want it to be.

I'd like to be the only one who can specify weather a new entry is to
be put through.

Any way to do this?
Thanks for the help.
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 6 Jan 2004 18:53:31 -0800, sp************@yahoo.com.au (James A) wrote:
I have 3 problems which I'd like people to solve for me (I've run out
of ideas)
1)

I have a table called s7-300. If i simply run this line of code:
lstResult.rowsource = "Select * FROM S7-300"

I will get a syntax error. So i have to rename my table. Is it
possible to leave the
table name alone and format that line of code so that it will work?
It would be good to rename your table because there are many cases where
special characters will cause you trouble (underscore is OK). If you do need
to query from such a table, though, just put square brackets around the name,
eg. Select * FROM [S7-300]
2)

My table "s7300" was imported from an excel datasheet. As such the
field numbers are
1,2,3,4,5 ect.

If i try a simple line of code as follows:

Lstresult.rowsource = "Select 1 FROM S7300"

As a result, i need to rename each of the fields manually. I would
like to be able
to accept data whilst they are named numerically.
Same deal. Those are not the best choices for field names, but you can refer
to them in queries by wrapping the names in square brackets, eg. Select [1]
FROM S7300
3)

This time I change the rowsourcetype to Value List.

I run this line of code:

lstresult.rowsource = "Title1;title2;" & blah.column(0,blah.listindex)
& ";" & blah.column(1,blah.listindex) & ";"

If any of the queried items has a comma "," in it, the listbox assumes
this means it is a new entry.
This results in the data not being formatted the way i want it to be.


You need double-quotes around the expressions in the list. To insert a
double-quote into a string constant as in your illustration, you need to
insert 2 consecutive double-quote characters, e.g. lstresult.rowsource =
"""Title1"";""title2"";""" & blah.column(0,blah.listindex) & """;""" &
blah.column(1,blah.listindex) & """;"

Nov 12 '05 #2

P: n/a
On 6 Jan 2004 18:53:31 -0800, sp************@yahoo.com.au (James A)
wrote:

1: If you use special characters like "-", use square brackets around
the name: [S7-300]
2: See 1.
3: Use single quotes around the text values.

-Tom.

I have 3 problems which I'd like people to solve for me (I've run out
of ideas)
1)

I have a table called s7-300. If i simply run this line of code:
lstResult.rowsource = "Select * FROM S7-300"

I will get a syntax error. So i have to rename my table. Is it
possible to leave the
table name alone and format that line of code so that it will work?
2)

My table "s7300" was imported from an excel datasheet. As such the
field numbers are
1,2,3,4,5 ect.

If i try a simple line of code as follows:

Lstresult.rowsource = "Select 1 FROM S7300"

As a result, i need to rename each of the fields manually. I would
like to be able
to accept data whilst they are named numerically.
3)

This time I change the rowsourcetype to Value List.

I run this line of code:

lstresult.rowsource = "Title1;title2;" & blah.column(0,blah.listindex)
& ";" & blah.column(1,blah.listindex) & ";"

If any of the queried items has a comma "," in it, the listbox assumes
this means it is a new entry.
This results in the data not being formatted the way i want it to be.

I'd like to be the only one who can specify weather a new entry is to
be put through.

Any way to do this?
Thanks for the help.


Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.