Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2006
    Posts
    16

    Unanswered: Help! What's wrong with this syntax

    Set qdfa = dbb.CreateQueryDef("", "SELECT * " & _
    "FROM [tbl_RFY_MO_TGT] " & _
    "WHERE int(LEFT([TNG_ID], 4)) = " & _
    iCFY & " AND " & _
    "MID([TNG_ID]5,9) = '" & rstb!MOS_9 & "' ")

    I keep getting a syntax error. I'm not good with all the 'quote' syntax.

    Kellie

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if its a text column thwn you need to encapsulate that item(s) in the appropriate quotes for the db you are using..

    assuming yuou are using VB/VBA I find using chr$(xx) much easier to read when debugging the text

    Code:
    Set qdfa = dbb.CreateQueryDef("", "SELECT * " & _
    "FROM [tbl_RFY_MO_TGT] " & _
    "WHERE int(LEFT([TNG_ID], 4)) = " & _
    iCFY & " AND " & _
    "MID([TNG_ID]5,9) = '" & rstb!MOS_9 & "' ")
    becomes
    Code:
    Set qdfa = dbb.CreateQueryDef("", "SELECT * FROM [tbl_RFY_MO_TGT]" & _
    " WHERE int(LEFT([TNG_ID], 4)) = " & chr$(34) & iCFY & chr$(34) & _
    " AND MID([TNG_ID]5,9) = '" & chr$(34) & rstb!MOS_9 & chr$(34) & ";")
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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