Syntax error (missing operator) in query expression

Discussion in 'ASP .Net' started by D, Jul 18, 2006.

  1. D

    D Guest

    I think this is a simple fix, but a second set of eyes could certainly
    help. Here is the error in it's entirety followed by my search criteria
    code. Any suggestions?

    Microsoft JET Database Engine error '80040e14'

    Syntax error (missing operator) in query expression 'LimitDate LIKE
    #7/18# WHERE skill in (select skill from tbl_timelimit where skill LIKE
    '%sales%' ) AND LimitDate >= #7/18/2006#'.

    /tier1overtime/overtime/TimeList.asp, line 220

    'Build dynamic sql.
    sql = "select * from tbl_TimeLimit "

    '--Name (partial and exact search)
    'If Not IsEmpty(reqname) Then
    if reqname<>"" then
    Dim strName
    strName = Trim(reqname)
    If strName <> "" Then
    'Test for WHERE
    If blnWhere Then sql = sql & " AND " Else sql = sql & " WHERE " :
    blnWhere = True
    sql = sql & "LimitDate LIKE #" & strName & "# "
    End If
    End If

    '--Name (partial and exact search)
    'If Not IsEmpty(reqcategory) Then
    if reqcategory<>"" then
    strName = Trim(reqcategory)
    If strName <> "" Then
    'Test for WHERE
    sql = sql & " WHERE skill in (select skill from tbl_timelimit where "
    : blnWhere = True
    If (Left(strName, 1) = "*" And Len(strName) > 1) Then 'Partial search
    sql = sql & "skill LIKE '%" & Replace(Mid(strName, 2), "'", "''") &
    "' "
    ElseIf (Right(strName, 1) = "*" And Len(strName) > 1) Then 'Partial
    search
    sql = sql & "skill LIKE '" & Replace(Mid(strName, 1,
    Len(strName)-1), "'", "''") & "%' "
    Else 'Exact match
    sql = sql & "skill LIKE '%" & Replace(strName, "'", "''") & "%' "
    End If
    sql = sql & ") "
    End If
    End If


    If blnWhere Then sql = sql & " AND " Else sql = sql & " WHERE " :
    blnWhere = True
    sql = sql & "LimitDate >= #" & date & "# "
    sql = sql & " ORDER BY LimitDate ASC"

    session("tmpSqlExcel")= sql
    D, Jul 18, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. D
    Replies:
    4
    Views:
    2,272
  2. alexz
    Replies:
    0
    Views:
    108
    alexz
    Jul 11, 2003
  3. Maciej Paras
    Replies:
    1
    Views:
    150
    Bob Barrows
    Oct 30, 2003
  4. shank
    Replies:
    26
    Views:
    369
    Bob Barrows [MVP]
    Aug 9, 2004
  5. Replies:
    4
    Views:
    188
    Bob Barrows
    Sep 30, 2005
Loading...

Share This Page