473,404 Members | 2,137 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,404 software developers and data experts.

What's wrong with this code? Compile Error...

I thought this was ok.... but... I get the following message: COMPILE
ERROR- EXPECTED END OF STATEMENT and the "Where" is highlighted. I'm a
bit of a novice at this so any help at all would be much appreciated!!

Thanks!
Private Sub Text18_AfterUpdate()

Dim db As Database
Dim strSQL As String

Set db = CurrentDb
strSQL = "UPDATE tblBusinessObjectives, tblPeriodDates SET
tblBusinessObjectives.intPeriod = tblPeriodDates!Period" WHERE
(((tblBusinessObjectives.DateCreated)>=[tblPeriodDates]![Start_Date]
And (tblBusinessObjectives.DateCreated)<=[tblPeriodDates]![End_Date]))

db.Execute strSQL
db.Close
End Sub
Nov 13 '05 #1
2 6947
On 18 Jan 2005 09:30:28 -0800, Layla wrote:
I thought this was ok.... but... I get the following message: COMPILE
ERROR- EXPECTED END OF STATEMENT and the "Where" is highlighted. I'm a
bit of a novice at this so any help at all would be much appreciated!!

Thanks!

Private Sub Text18_AfterUpdate()

Dim db As Database
Dim strSQL As String

Set db = CurrentDb
strSQL = "UPDATE tblBusinessObjectives, tblPeriodDates SET
tblBusinessObjectives.intPeriod = tblPeriodDates!Period" WHERE
(((tblBusinessObjectives.DateCreated)>=[tblPeriodDates]![Start_Date]
And (tblBusinessObjectives.DateCreated)<=[tblPeriodDates]![End_Date]))

db.Execute strSQL
db.Close

End Sub.


Move the double quote before the word WHERE to the end of the SQL.
Everything you have after that " is not in the strSQL string.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #2
la*******@hotmail.com (Layla) wrote:
I thought this was ok.... but... I get the following message: COMPILE
ERROR- EXPECTED END OF STATEMENT and the "Where" is highlighted. I'm a
bit of a novice at this so any help at all would be much appreciated!!

Thanks!
Private Sub Text18_AfterUpdate()

Dim db As Database
Dim strSQL As String

Set db = CurrentDb
strSQL = "UPDATE tblBusinessObjectives, tblPeriodDates SET
tblBusinessObjectives.intPeriod = tblPeriodDates!Period" WHERE
(((tblBusinessObjectives.DateCreated)>=[tblPeriodDates]![Start_Date]
And (tblBusinessObjectives.DateCreated)<=[tblPeriodDates]![End_Date]))

db.Execute strSQL
db.Close
End Sub


There is a double quote " just before WHILE that should not be there.
Is the code folowing strSQL = all on one line? If yes, the double
quote shoult be at the very end of the line.

You can break the statement into several lines as follows:

strSQL = "UPDATE tblBusinessObjectives, tblPeriodDates " & _
" SET tblBusinessObjectives.intPeriod = tblPeriodDates!Period " & _
" WHERE (((tblBusinessObjectives.DateCreated) >= " & _
" [tblPeriodDates]![Start_Date] " & _
" And (tblBusinessObjectives.DateCreated) <= " & _
" [tblPeriodDates]![End_Date]));"

That is, you write a continuation line with a Space and an Underline,
but then you have to put together the separate strings with the &
operator. You cannot break a line in the middle of a string.
(I'm using too many line breaks here because of the wrapping of the
Newsgroups editor.)

HTH
Matthias Kläy
--
www.kcc.ch
Nov 13 '05 #3

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

Similar topics

2
by: marco | last post by:
the problem: I use a typedef inside a class template, than I use this type (dim_v<N1>::Type) to define the argument of a template function f but when I call this function from main, the compiler...
5
by: titan0111 | last post by:
#include<iostream> #include<iomanip> #include<cstring> #include<fstream> using namespace std; class snowfall { private: int ft;
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
10
by: bob | last post by:
Hello, I use Microsoft Visual C++ .NET (version 7.1.3088) Sometimes (with big codes?) when I get a compile error and click on the error, the cursor is placed next to the wrong piece of code. The...
10
by: Protoman | last post by:
Could you tell me what's wrong with this program, it doesn't compile: #include <iostream> #include <cstdlib> using namespace std; class Everything { public: static Everything* Instance()
3
by: farseer | last post by:
i am getting "error C2057: expected constant expression" with the following code: ifstream f( argv ); f.seekg( 0, ios::end ); const long fSize = f.tellg(); f.close(); char content;
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Languageâ€, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader =...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.