473,383 Members | 1,801 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,383 software developers and data experts.

SQL Statement Error

171 100+
Hi,

When I put this code in I get the error: Invalid SQL Statement, Expected 'DELETE', 'INSERT', 'PROCEEDURE', 'SELECT' or 'UPDATE'

Expand|Select|Wrap|Line Numbers
  1. strSqlYear = "SELECT tblJobDetails.TFN, tblJobDetails.ReturnType, tblYearsPerReceipt.Year FROM tblJobDetails, tblYearsPerReceipt WHERE (tblJobDetails.TFN)= " & Me.tbTFN & " AND (tblJobDetails.ReturnType)= " & Me.cboReturnType & " AND (tblYearsPerReceipt.Year)= " & Me.cboYear
Extra Info
1. I have done Dim strStrYear as String
2. Me.tbTFN is a textbox in the form to which this code relates
3. Me.cboReturnType is a ComboBox in the form to which this code relates
4. Me.cboYear is a ComboBox in the form to which this code relates

any help would be much appreciated.


Best Regards
Jan 31 '08 #1
6 1129
Delerna
1,134 Expert 1GB
Can't see anything immediately obvious.
Try returning the SQL string in a message box or setting a breakpoint
on the line after building the SQL string so that you can have a look at the contents of the string and see if it looks as it should.

The error suggests that the string hasn't been built correctly, for example
a space missing or a value comming in as a reserved word or some such thing
Jan 31 '08 #2
iheartvba
171 100+
Can't see anything immediately obvious.
Try returning the SQL string in a message box or setting a breakpoint
on the line after building the SQL string so that you can have a look at the contents of the string and see if it looks as it should.

The error suggests that the string hasn't been built correctly, for example
a space missing or a value comming in as a reserved word or some such thing
Hi,

actually I've left out something quite important in my last post, I'm runing this query via ADO so the dimensions for cnn are Public cnn As ADODB.Connection
and the dimensions for rst are Public rst As New ADODB.Recordset. Don't Know if that makes a difference. Also I had previously made the SQL in the Query Builder (the queries name was "qryDuplicateYear") and just ran rst.open "qryDuplicateYear" , and when I removed the criteria it worked fine, when I put the criteria back in then it again gave this problem. so this is some additional code from that proceedure which may help.

Expand|Select|Wrap|Line Numbers
  1. Set cnn = CurrentProject.Connection
  2. If Me.cboReturnType = 1 Or 2 Or 3 Or 4 Or 5 Or 14 Or 15 Then
  3. 'StrSqlYear is shown in my first post
  4. rst.Open "strSqlYear", cnn, adOpenKeySet, adLockOptimistic
  5.     With rst
  6.     If rst.RecordCount > 0 Then
  7.     MsgBox "This Client Already has A " & Me.cboReturnType & " For The " & Me.cboYear & " Financial Year"
  8. End If
  9. End With
  10.  
Feb 1 '08 #3
Delerna
1,134 Expert 1GB
do either of the combo boxes have more than 1 column
Feb 1 '08 #4
iheartvba
171 100+
do either of the combo boxes have more than 1 column
Yes They do but the information I want is in the 1st Column I.E. I do not need to say Me.cboReturnType.Column(1). and Even if I put just the Me.tbTFN crtieria it still gives the same problem
Feb 1 '08 #5
iheartvba
171 100+
Excuse me Delerna my brain went on strike today so I havent got much to work with, I had set the string as strSqlYear and then I put it in quotes again when I did rst.open so i did rst.open "strSqlYear".
Feb 1 '08 #6
Delerna
1,134 Expert 1GB
LOL
I didn't notice that either, its obvious after you find it isn't it :)
Feb 1 '08 #7

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

Similar topics

1
by: Jay | last post by:
G'day all This registration form checks for the submit button then displays the next form from the include statement. But before it displays the next form it will check to make sure the user...
3
by: Robert Mark Bram | last post by:
Hi All! I have the following two methods in an asp/jscript page - my problem is that without the update statement there is no error, but with the update statement I get the following error: ...
4
by: James E Koehler | last post by:
I can't get the WHILE statement to work in MySQL. The version of MySQL that I am using is: Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32) running on Windows MX. Here is the relevant...
1
by: Jack | last post by:
Hi, I got a asp page where I am getting the following error. (Line 126 is actually the RS.open statement.) ERROR MESSAGE Technical Information (for support personnel) Error Type:
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
1
by: amitbadgi | last post by:
HI i am getting the foll error while conv an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Syntax error in UPDATE statement. Source Error: Line...
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
20
by: John Salerno | last post by:
I'm starting out with this: try: if int(text) 0: return True else: self.error_message() return False except ValueError: self.error_message()
8
by: Guybrush Threepwood | last post by:
This is a simplified example of a problem I'm having: typedef struct node { int a; int b; } NODE; Somewhere in my code following lines can be found: switch(op) {
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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...

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.