473,387 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SQL Statement - Expected : End of Statement

I would appreciate if someone could correct my SQL statement which is
displaying a message Expected : End of Statement this statment is
attached to a button on the form

StrSQL = "PARAMETERS [Forms]![FrmAccrualMain]![ProjectGroupID] Long;"
& _
"TRANSFORM Sum(QryBudget.Amount) AS SumOfAmount" & _
"SELECT QryBudget.[Cost Elements], QryBudget.SAPAccountName,
QryBudget.Order" & _
"FROM QryBudget WHERE (((QryBudget.ProjectID) =
[Forms]![FrmAccrualMain]![ProjectGroupID]))" & _
"GROUP BY QryBudget.[Cost Elements], QryBudget.SAPAccountName,
QryBudget.Order PIVOT Format([Month],"mmm/yy") In (TxtMonths);"

Thanks
Edward
Nov 12 '05 #1
2 11258
Hi Edward,

1.) The first thing that I would do in your situation is to add a
"Debug.Print StrSQL" below this code, and then try to run it.
2.) The resulting SQL string will then be available from the Immediate
(Debug) window.
3.) Copy that SQL, then create a new query. Open that query's SQL view and
past in the copied SQL.
4.) Try to switch to datasheet view.
5.) Access will complain, giving you the same "Expected: End of Statement"
error, but this time it will quite likely HIGHLIGHT the offending portion
for you.
6.) My guess is that it will be the ";" at the end of the first line. ";" is
I believe, the signal for the end of the SQL string.
--------------------------------------------------------------------------

All of the above being said... I have one more opinion to express: UGH!
I hate that underscore "line continuation" thing. It really seems to cause
more confusion and problems than it fixes!

Here's what I do instead:
---------------------------
StrSQL = "" 'Clear the string variable
StrSQL = StrSQL & "PARAMETERS [Forms]![FrmAccrualMain]![ProjectGroupID] Long
"
StrSQL = StrSQL & "TRANSFORM Sum(QryBudget.Amount) AS SumOfAmount "
StrSQL = StrSQL & "SELECT QryBudget.[Cost Elements],
QryBudget.SAPAccountName, QryBudget.Order "
StrSQL = StrSQL & "FROM QryBudget WHERE (((QryBudget.ProjectID) = "
StrSQL = StrSQL & [Forms]![FrmAccrualMain]![ProjectGroupID]
StrSQL = StrSQL & ")) "
StrSQL = StrSQL & "GROUP BY QryBudget.[Cost Elements],
QryBudget.SAPAccountName, QryBudget.Order "
StrSQL = StrSQL & "PIVOT Format([Month],"mmm/yy") In (TxtMonths)"
StrSQL = StrSQL & ";"

Debug.Print StrSQL

--
HTH,
Don
=============================
Use My*****@Telus.Net for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================

"Edward S" <so******@qatar.net.qa> wrote in message
news:57*************************@posting.google.co m...
I would appreciate if someone could correct my SQL statement which is
displaying a message Expected : End of Statement this statment is
attached to a button on the form

StrSQL = "PARAMETERS [Forms]![FrmAccrualMain]![ProjectGroupID] Long;"
& _
"TRANSFORM Sum(QryBudget.Amount) AS SumOfAmount" & _
"SELECT QryBudget.[Cost Elements], QryBudget.SAPAccountName,
QryBudget.Order" & _
"FROM QryBudget WHERE (((QryBudget.ProjectID) =
[Forms]![FrmAccrualMain]![ProjectGroupID]))" & _
"GROUP BY QryBudget.[Cost Elements], QryBudget.SAPAccountName,
QryBudget.Order PIVOT Format([Month],"mmm/yy") In (TxtMonths);"

Thanks
Edward

Nov 12 '05 #2
Thanks Don Your suggestion did work for me

Best Regards
Edward

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Phil Powell | last post by:
Here is the function ArraySearch: '-------------------------------------------------------------------------------------- 'ArraySearch will return an integer value indicating the first...
7
by: Graham James Campbell CS2000 | last post by:
Having a nightmare problem with this and would appreciate any and all help. The situation is I want to move from a webform and format the user inputted text into some html I am storing in a...
6
by: Oli | last post by:
Hi, Im trying to use a sesson statement within an SQL Statement: sql = "SELECT * FROM tblNumbers WHERE AllocatedTo=" & Session("Company") & "" And get the error: Error Type:
3
by: Matt | last post by:
When the ASP statement end with a _ character, then the next line cannot have comment ' character. Is that correct? Since I encountered the following error: Microsoft VBScript compilation...
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
2
by: Edward S | last post by:
I would appreciate if someone could correct my SQL statement which is displaying a message Expected : End of Statement this statment is attached to a button on the form StrSQL = "PARAMETERS !!...
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
1
by: Jean-Marc Blaise | last post by:
Hi folks, In case the SQL statement is not written properly, we sometimes get strange messages. The 2 following statements are simple inversion between order by and group by clause. We get an...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
1
by: nosaj070 | last post by:
Hi, I'm working on a project and it is my first time implementing VBA with Access. I know my SQL Statement is close, but it obviously isn't perfect, if any of you can see what the error is I'd really...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.