473,473 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Syntax error in from clause

19 New Member
Again am sorry for not leaving to expectation on this website, This may be because am new but I promise to adjust.
I have a table "tblfeesdetails" which is updated by a command button click from a form belonging to another table. In the above mentioned table (tblfeesdetails), I have the following fields; GroudpID, ...,BillDate. Now I want to select all the records or data updated just now or (to day) based on two criteria thus Groupid and BillDate. But I am prompted with "Syntax error in FROM clause. The line Set rstd = CurrentDb.OpenRecordset(strSQLDetails) is highlighted with yellow colour meaning that the error is comming from here.

Expand|Select|Wrap|Line Numbers
  1.  strSQLDetails = "SELECT tFD.* " & _
  2.                 "FROM   [tblFeesDetails] AS tFD" & _
  3.                 "       INNER JOIN" & _
  4.                 "      (SELECT Now([BillDate]) AS [NowDT]" & _
  5.                 "       FROM   [tblFeesDetails]" & _
  6.                 "       WHERE  ([GroupID] =  '%G'"")AS sQ" & _
  7.                 "  ON   tFD.[BillDate] = sQ.NowDT " & _
  8.                 "WHERE  (tFD.GroupID = '%G'"";"
  9.  
  10. strSQLDetails = Replace(strSQLDetails, "%G", mgroupid)
  11.  
  12.      Set rstd = CurrentDb.OpenRecordset(strSQLDetails)
Mar 22 '11 #1
2 5691
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
I suggest you read this insights article on VBA debugging:
Debugging VBA code

Reading your post would be alot easier if you would bother to use the Code bbtags, but im guessing the issue is too many quotes around the %G, or an emty mGroupID. But read the debugging article and you will be able to spot such mistakes easy enough.
Mar 22 '11 #2
NeoPa
32,556 Recognized Expert Moderator MVP
Emmanuel:
Again am sorry for not leaving to expectation on this website, This may be because am new but I promise to adjust.
Always a welcome comment. There is a FAQ available to help you come to understand all that is expected of you as a poster. We feel all the requirements are reasonable, and they are there for the benefit of all involved - not just we who run the site, but also all those of you who use it too. We always welcome such a statement of intent though :-)

Now the code tags are in place (and I can see you've laid your code out well to be easily readable) I suspect your problem(s) lie with extraneous double quotes (Lines #6 & #8) and possibly the misuse of the function Now() on line #4.

I don't have my Bytes database available ATM but I have some text in there that explains how to debug such things. I'll repeat some of it here, but possibly not the full version.

Basically, what you should be doing when working with SQL created in VBA is to separate the two out. This involves using something like Debug.Print strSQLDetails after it's been set up, and looking at what's in there. In this case it would show something like :

Expand|Select|Wrap|Line Numbers
  1. SELECT tFD.* FROM   [tblFeesDetails] AS tFD       INNER JOIN      (SELECT Now([BillDate]) AS [NowDT]       FROM   [tblFeesDetails]       WHERE  ([GroupID] =  '???'")AS sQ  ON   tFD.[BillDate] = sQ.NowDT WHERE  (tFD.GroupID = '???'";
I haven't formatted it as I normally would SQL, because it's exactly what you need to look at. Spaces and all. It's much easier to work with SQL directly than it is to work with what you think aught to come out after VBA has finished creating it for you.
Mar 22 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Sean | last post by:
HI There, I am trying to submit a form when a selection is made from a dropdown list, I keep getting the error "Handles clause requires With Events Variable". Could someone help me with the...
3
by: Jerry | last post by:
Well, here is some weirdness. First, I noticed that I have 2 Set keywords (silly me). so I removed the 2nd "Set" but still got a syntax error. Then I removed the Where clause, and now it works...
2
by: Bob Alston | last post by:
I am going blind tonight but I cannot figure out the error. I get a syntax error from this sql statement, being run via vba in access 2003 insert into tbl_Volunteer_Donor in...
2
by: isaac2004 | last post by:
hello i am getting a weird al syntax error from my SQL statement Microsoft OLE DB Provider for ODBC Drivers error '80040e14' Syntax error (missing operator) in query expression...
11
by: Frankie | last post by:
Hello: New user here...first post to group. I'm getting an SQL syntax error when I try to run the following query: $query = sprintf("SELECT itemNumber, entryDate, modifyDate, thumbnailURL,...
1
by: darrel | last post by:
hi there can anyone tell me wats wrong with my program, its a like this i have a database called "dbTimescheduling", with a field with a name of "Time",,, for now i want to do is to be able to access...
3
by: bilbo | last post by:
Can anybody help me understand why I get the error "Syntax error in CONSTRAINT clause"? I get it in Access 2003 and Access 2007. Both are clean installs with no add-ins Running this code in...
5
by: stanman | last post by:
I have been trying to get past this error all day. I am unable to determine why I get syntax error from the following code: //modify a record $myDataID = mysql_query("UPDATE members SET...
20
by: billmaclean1 | last post by:
I need to write a stored procedure that selects from a table and returns the result set. I don't always know the TableSchema that I need to use when qualifying the table at run-time Example:...
11
guillermobytes
by: guillermobytes | last post by:
Hi, i'm making a query with PDO and there is a SQL syntax error in it. $sql = 'BAD CODE'; $pdoStmt = $pdo->prepare($sql); if (false === $pdoStmt) { echo 'ERROR'; }
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
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...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.