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

access sql error

Hi All
Can any one please help. I get an error code 3141 when I try run this sql statement. I have tried it from an HTA App and from Acess and get the error from both.

"Select top 1,* from tblCustomers where CustomerId >= " & Cstr(CurrentID)

Any help would be good

Ta in advance
Sep 2 '07 #1
8 2017
FishVal
2,653 Expert 2GB
Hi All
Can any one please help. I get an error code 3141 when I try run this sql statement. I have tried it from an HTA App and from Acess and get the error from both.

"Select top 1,* from tblCustomers where CustomerId >= " & Cstr(CurrentID)

Any help would be good

Ta in advance
Hi, there.
  • are you sure tblCustomers.CustomerId is numeric type field ?
  • are you sure Cstr(CurrentID) doesn't evaluate to empty string ?
  • add terminating ";" to the expression
Sep 2 '07 #2
Hi FishVal

Yeah to all questions and have also added ; terminator
Sep 2 '07 #3
Hi, there.
  • are you sure tblCustomers.CustomerId is numeric type field ?
  • are you sure Cstr(CurrentID) doesn't evaluate to empty string ?
  • add terminating ";" to the expression
The full error report read:
The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect

I have read the access help files and acording to it, my statement is correct.
Sep 2 '07 #4
FishVal
2,653 Expert 2GB
The full error report read:
The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect

I have read the access help files and acording to it, my statement is correct.
According to Access TOP N predicate has not been separated with comma from fieldslist, but anyway int runs with comma as well as w/o. :)
Did you try to gather in debug mode actual sql string content and run it in query builder?
Sep 2 '07 #5
yeah and it still has the same error

if it will help here is my code that uses the sql

Sub NextCustomer()
dim objConn, strConnection, objRS, strQuery, TheForm
set objConn = CreateObject("ADODB.Connection")
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\order entry\orders.mdb'"
objConn.Open strConnection
set objRS = CreateObject("ADODB.RecordSet")
CurrentNum = CurrentNum + 1
if CurrentNum <NumRecords then
CurrentID = CurrentID + 1
strQuery = "Select top 1,* from tblCustomers where CustomerId >= " & Cstr(CurrentID)
objRS.Open strQuery, objConn,3,1
CurrentID = objRS("CustomerId")

set TheForm = Document.Forms("EditCustomersForm")
TheForm.id.value = objRS("CustomerId")
TheForm.FirstName.Value = objRS("FirstName")
TheForm.LastName.Value = objRS("LastName")
TheForm.Street.Value = objRS("Street")
TheForm.City.Value = objRS("City")
TheForm.State.Value = objRS("State")
TheForm.Zip.Value = objRS("Zip")
TheForm.Phone.Value = objRS("Phone")
TheForm.Email.Value = objRS("Email")
TheForm.Notes.Value = objRS("Notes")
objRS.Close
end if
objConn.Close
set objRS = nothing
set objConn = nothing

end sub
Sep 2 '07 #6
FishVal
2,653 Expert 2GB
yeah and it still has the same error

if it will help here is my code that uses the sql

Sub NextCustomer()
dim objConn, strConnection, objRS, strQuery, TheForm
set objConn = CreateObject("ADODB.Connection")
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\order entry\orders.mdb'"
objConn.Open strConnection
set objRS = CreateObject("ADODB.RecordSet")
CurrentNum = CurrentNum + 1
if CurrentNum <NumRecords then
CurrentID = CurrentID + 1
strQuery = "Select top 1,* from tblCustomers where CustomerId >= " & Cstr(CurrentID)
objRS.Open strQuery, objConn,3,1
CurrentID = objRS("CustomerId")

set TheForm = Document.Forms("EditCustomersForm")
TheForm.id.value = objRS("CustomerId")
TheForm.FirstName.Value = objRS("FirstName")
TheForm.LastName.Value = objRS("LastName")
TheForm.Street.Value = objRS("Street")
TheForm.City.Value = objRS("City")
TheForm.State.Value = objRS("State")
TheForm.Zip.Value = objRS("Zip")
TheForm.Phone.Value = objRS("Phone")
TheForm.Email.Value = objRS("Email")
TheForm.Notes.Value = objRS("Notes")
objRS.Close
end if
objConn.Close
set objRS = nothing
set objConn = nothing

end sub
Add space between "," and "*"
"Select top 1, * from tblCustomers where CustomerId >= " & Cstr(CurrentID)
;)

And the comma is not needed, and Cstr is not needed (& operator concatenates variables of all types with string), and, G..d save us, add terminating semicolon ";".
"Select top 1 * from tblCustomers where CustomerId >= " & CurrentID & ";"

Regards

Fish
Sep 2 '07 #7
Ta very much (Blush) . It's working now. Strange how one can overlook such simple things. Just shows you two pairs of eyes are better that one
Sep 2 '07 #8
FishVal
2,653 Expert 2GB
Ta very much (Blush) . It's working now. Strange how one can overlook such simple things. Just shows you two pairs of eyes are better that one
Not a problem. You are welcome.

Regards

Fish
Sep 2 '07 #9

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

Similar topics

3
by: Nicola | last post by:
Hi Everyone, I am new to programming and would like to know how to open an access Report from within vb 6. I am trying to write a program to organise cross stitch threads. I have found out how...
4
by: Fabian von Romberg | last post by:
Hi, I have installed Sql Reporting Services on 2 machines, one is WIN 2000 PRO and the other one is WIN 2000 ADV. SERVER. When I try to access a report using the webbrowser, I get the following...
1
by: annie | last post by:
Hi all, I have recently ported my Access 2000 app to SQL Server, keeping the Access client as the front end using linked tables. I am also using triggers on my SQL tables to trap orphan...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
9
by: Fish Womper | last post by:
I am at best a part time developer of Access databases. I use Access 2.0, as this is all my employer has on its computers. Even so, to use this ancient version requires a fairly convoluted...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
0
by: Sebastian | last post by:
Hello I develop my applications in Access 2002. My development system is running Windows XP SP2 and I have Microsoft Office XP Developer. Microsoft Office XP is at SP3. I used Inno Setup (great...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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
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
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...
0
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: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.