Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    215
    Thanks
    14
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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) & ";"
    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.

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    215
    Thanks
    14
    Thanked 0 Times in 0 Posts
    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

  • #4
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •