|
Prev: DirListBox Relative Path
Next: simple string encryption
From: PSULionRP on 3 Jul 2008 11:36 How can I continue a SQL Serever call in a Visual Basic Sub Procedure??? I have this syntax... .Open "SELECT Table1.Column1 _ , RTrim(LTrim(Table2.Column1)) _ , RTrim(LTrim(Table1.Column2)) _ , RTrim(LTrim(Table1.Column3)) _ FROM Table1 Table1 _ INNER JOIN Table2 Table2 _ ON Table1.Column1 = Table2.Column1 _ WHERE Table1.Column1 IN ('Value1','Value2','Value3')" I thought I could continue my SQL syntax with an "_" but I always seem to get the error message on the FROM which states... Compile error: Expected: end of statement Can someone help me out here??? Thanks in advance for your help. PSULionRP
From: RDub on 3 Jul 2008 12:03 You must Concatenate the quoted strings with ampersands and opening and closing quotes Open "SELECT Table1.Column1 " _ & ", RTrim(LTrim(Table2.Column1)) " _ & ", RTrim(LTrim(Table1.Column2)) " _ .... Rdub "PSULionRP" <PSULionRP(a)discussions.microsoft.com> wrote in message news:06F5966A-68B5-47E2-AF12-81B0BF936761(a)microsoft.com... > How can I continue a SQL Serever call in a Visual Basic Sub Procedure??? > > I have this syntax... > > .Open "SELECT Table1.Column1 _ > , RTrim(LTrim(Table2.Column1)) _ > , RTrim(LTrim(Table1.Column2)) _ > , RTrim(LTrim(Table1.Column3)) _ > FROM Table1 Table1 _ > INNER JOIN Table2 Table2 _ > ON Table1.Column1 = Table2.Column1 _ > WHERE Table1.Column1 IN ('Value1','Value2','Value3')" > > I thought I could continue my SQL syntax with an "_" but I always seem to > get the error message on the FROM which states... > > Compile error: > > Expected: end of statement > > Can someone help me out here??? > > Thanks in advance for your help. > > PSULionRP >
From: MikeD on 4 Jul 2008 10:16 "PSULionRP" <PSULionRP(a)discussions.microsoft.com> wrote in message news:06F5966A-68B5-47E2-AF12-81B0BF936761(a)microsoft.com... > How can I continue a SQL Serever call in a Visual Basic Sub Procedure??? > > I have this syntax... > > .Open "SELECT Table1.Column1 _ > , RTrim(LTrim(Table2.Column1)) _ > , RTrim(LTrim(Table1.Column2)) _ > , RTrim(LTrim(Table1.Column3)) _ > FROM Table1 Table1 _ > INNER JOIN Table2 Table2 _ > ON Table1.Column1 = Table2.Column1 _ > WHERE Table1.Column1 IN ('Value1','Value2','Value3')" > > I thought I could continue my SQL syntax with an "_" but I always seem to > get the error message on the FROM which states... > > Compile error: > > Expected: end of statement > > Can someone help me out here??? > You can't split a string among multiple lines like that. You still have to concatenate it like this: .Open "SELECT Table1.Column1" _ & " , RTrim(LTrim(Table2.Column1)) " _ & " , RTrim(LTrim(Table1.Column2)) " _ & " , RTrim(LTrim(Table1.Column3)) " _ & " FROM Table1 Table1 " _ & " INNER JOIN Table2 Table2 " _ & " ON Table1.Column1 = Table2.Column1 " _ & " WHERE Table1.Column1 IN ('Value1','Value2','Value3')" -- Mike Microsoft MVP Visual Basic
|
Pages: 1 Prev: DirListBox Relative Path Next: simple string encryption |