Go Back   CodingForums.com > :: Server side development > MySQL > Other Databases

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-10-2007, 10:10 PM   PM User | #1
parallon
Regular Coder

 
Join Date: May 2005
Posts: 215
Thanks: 14
Thanked 0 Times in 0 Posts
parallon is an unknown quantity at this point
Syntax error (comma) in query expression

Hello all. I have an error that has just showed up. The error is as follows:

Code:
Microsoft JET Database Engine error '80040e14' 

Syntax error (comma) in query expression 'id = 1,382'. 

/Timesheet/EQ_EditTime.asp, line 26
Here is the query:

Code:
SELECT * FROM tblEqMilesHours  WHERE id = " & RecId & "

... and I think that it has something to do with the 'id' being a four digit number. In the database it is set up as an autonumber. What do I need to do to get rid of this error?

Thanks,

Parallon
parallon is offline   Reply With Quote
Old 09-10-2007, 10:45 PM   PM User | #2
Daemonspyre
Regular Coder

 
Join Date: Mar 2007
Posts: 505
Thanks: 1
Thanked 19 Times in 19 Posts
Daemonspyre is on a distinguished road
Make sure that you have a cInt(RecID) and that should help remove this error.

The problem is that you are trying to look at data with a COMMA in it, and Access doesn't recognize it.

Code:
"SELECT * FROM tblEqMilesHours WHERE id = " & cInt(RecID) & ";"
__________________
Quote:
To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
Please, if you found my post helpful, pay it forward. Go and help someone else today.
Daemonspyre is offline   Reply With Quote
Old 09-10-2007, 11:37 PM   PM User | #3
parallon
Regular Coder

 
Join Date: May 2005
Posts: 215
Thanks: 14
Thanked 0 Times in 0 Posts
parallon is an unknown quantity at this point
Thank you so much. That worked perfectly. I got it working by changing the variable to a string, but I feel your way is more correct.

Thanks again,

Parallon
parallon is offline   Reply With Quote
Old 02-23-2011, 07:04 AM   PM User | #4
bseyedes
New to the CF scene

 
Join Date: Feb 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
bseyedes is an unknown quantity at this point
syntex error comma

Your Question
syntex error (comma) in query?
I have no idea whay I get this error.
I have warehouse as text, I am using a list box to get my WHs, from the list I get WH In (("381","320)) which makes sence but i get the syntex error (comma) in query expenssion error

Me.Visible = False
Dim i As Integer
Dim str As String
Dim strSQL As String
Dim qdef As DAO.QueryDef
Dim MyDB As DAO.Database
Dim strWhere As String
Dim strIN As String
Dim flgSelectAll As Boolean
Dim varItem As Variant
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "qry_FINALAvailablePhysical-Stock"


'Build the IN string by looping through the listbox
For i = 0 To List7.ListCount - 1
If List7.Selected(i) Then
If List7.Column(0, i) = "All" Then
flgSelectAll = True
End If
strIN = strIN & List7.Column(0, i) & """" & "," & """"

End If
Next i

'Create the WHERE string, and strip off the last comma of the IN string
str = "(""" & Left(strIN, Len(strIN) - 2) & ")"

'If "All" was selected in the listbox, don't add the WHERE condition
If flgSelectAll Then
DoCmd.OpenReport stDocName, acPreview
End If

'Clear listbox selection after running query
For Each varItem In Me.List7.ItemsSelected
Me.List7.Selected(varItem) = False
Next varItem


strSQL = " WH In ( " & str & " )"


DoCmd.OpenReport stDocName, acPreview, , strSQL
bseyedes is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:14 PM.


Advertisement
Log in to turn off these ads.