Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error: Syntx Error

Status
Not open for further replies.

PedroDC

Technical User
Feb 28, 2007
3
PT
Greetings!

Recently I started using VBA to programm Microsoft Query, with help of Macro Recorder (wich seems to make somewhat of a mess).

Relative to the code below I get "Compile Error: Syntax Error" and can't understand why:


.CommandText = Array( _
"SELECT Groups.`Group Name`, `Flown Revenue 2005`.`Agent Code`, Sum(`Flown Revenue 2005`.Coupons) as [Cpns]" & Chr(13) & "" & Chr(10) & "FROM {oj `C:\My Documents\Temporário\Unify\db2006 November-onward Compact`.`Flown Revenue 20" _
, _
"05` `Flown Revenue 2005` LEFT OUTER JOIN `C:\My Documents\Temporário\Unify\db2006 November-onward Compact`.Groups Groups ON `Flown Revenue 2005`.`Agent Code` = Groups.`Agent Code`}" & Chr(13) & "" & Chr(10) & "WHERE Groups.`Group Name`" & " = " & cmdComboBox.Text &" Chr(13) & "" & Chr(10) & "GROUP BY Groups.`G" _
, "roup Name`, `Flown Revenue 2005`.`Agent Code`")


Please advise
Thanks!
 
try testing your query directly in the database before embedding it into your VBA code

that way, you will get the correct error message

r937.com | rudy.ca
 
That's the question.

I can't create a Parameter Query in Mic Query. I must create a Macro to edit accordingly.

The problem arises in VBA. I can't detect any Syntax Error.

However, because I don't usually work SQL in VBA I may be missing something, hence my decision to create a Thread here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top