Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba.ado
Thread: Writing SQL

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Writing SQL
Tylendal 16.09.2006 13:05:01
I would like to write a single SQL statement that would allow me to place
different table names as needed and specify specific fields from this table.

The issue I am stumbling over is there are 30+ fields that have names like
1A, 2B, 4C, etc.

Each time the SQL runs I wish to select a specific field but for some reason
I get syntax errors. I can assign the field to a variable but getting the
variable into the SQL seems to be the issue. The SQL works fine if I
identify the field as 1A, 2B etc. but using the variable I get the error.

Appreciate your assistance.

Tylendal

Re: Writing SQL
John Nurick <j.mapSoN.nurick[ at ]dial.pipex.com> 16.09.2006 18:01:54
Hi Tylendal,

strField1 = "1A"
strField2 = "4C"
strTable = "MyTable"

strSQL = "SELECT [" & strField1 & "], [" & strField2 & "] " _
& "FROM " & strTable & ";"



On Sat, 16 Sep 2006 06:05:01 -0700, Tylendal
<Tylendal[ at ]discussions.microsoft.com> wrote:

[Quoted Text]
>I would like to write a single SQL statement that would allow me to place
>different table names as needed and specify specific fields from this table.
>
>The issue I am stumbling over is there are 30+ fields that have names like
>1A, 2B, 4C, etc.
>
>Each time the SQL runs I wish to select a specific field but for some reason
>I get syntax errors. I can assign the field to a variable but getting the
>variable into the SQL seems to be the issue. The SQL works fine if I
>identify the field as 1A, 2B etc. but using the variable I get the error.
>
>Appreciate your assistance.
>
>Tylendal

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Re: Writing SQL
Tylendal 19.09.2006 00:27:01
Thanks John...

When I saw your answer I asked myself why had I not thought of the [].
Appreciate the help.

-Tylendal

"John Nurick" wrote:

[Quoted Text]
> Hi Tylendal,
>
> strField1 = "1A"
> strField2 = "4C"
> strTable = "MyTable"
>
> strSQL = "SELECT [" & strField1 & "], [" & strField2 & "] " _
> & "FROM " & strTable & ";"
>
>
>
> On Sat, 16 Sep 2006 06:05:01 -0700, Tylendal
> <Tylendal[ at ]discussions.microsoft.com> wrote:
>
> >I would like to write a single SQL statement that would allow me to place
> >different table names as needed and specify specific fields from this table.
> >
> >The issue I am stumbling over is there are 30+ fields that have names like
> >1A, 2B, 4C, etc.
> >
> >Each time the SQL runs I wish to select a specific field but for some reason
> >I get syntax errors. I can assign the field to a variable but getting the
> >variable into the SQL seems to be the issue. The SQL works fine if I
> >identify the field as 1A, 2B etc. but using the variable I get the error.
> >
> >Appreciate your assistance.
> >
> >Tylendal
>
> --
> John Nurick [Microsoft Access MVP]
>
> Please respond in the newgroup and not by email.
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net