Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Syntex Error, Missing Operator !!!

Syntex Error, Missing Operator !!!

Scheduled Pinned Locked Moved Database
databasehelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    scorp_scorp
    wrote on last edited by
    #1

    Dear All, Am getting sytex error , Missing operator on the following: sqls = "SELECT c_number, c_description, c_scope, c_category, c_type FROM tb_c WHERE c_scope = " & scope & " AND c_number In select c_number FROM tb_c_details WHERE e_id = " & eid set rst = db.openrecordset (sqls) Cant find any missing operator :~ , also i used a msgbox to show sqls , the statement is perfect. Helpppp !!! :(

    0 will always beats the 1.

    L W 2 Replies Last reply
    0
    • S scorp_scorp

      Dear All, Am getting sytex error , Missing operator on the following: sqls = "SELECT c_number, c_description, c_scope, c_category, c_type FROM tb_c WHERE c_scope = " & scope & " AND c_number In select c_number FROM tb_c_details WHERE e_id = " & eid set rst = db.openrecordset (sqls) Cant find any missing operator :~ , also i used a msgbox to show sqls , the statement is perfect. Helpppp !!! :(

      0 will always beats the 1.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      scorp_scorp wrote:

      Helpppp !!!

      All examples I've seen have parentheses following the IN keyword... :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      S 1 Reply Last reply
      0
      • L Luc Pattyn

        scorp_scorp wrote:

        Helpppp !!!

        All examples I've seen have parentheses following the IN keyword... :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        S Offline
        S Offline
        scorp_scorp
        wrote on last edited by
        #3

        Modified to: sqls = "SELECT c_number, c_description, c_scope, c_category, c_type FROM tb_c WHERE c_scope = " & scope & " AND c_number In ( select c_number FROM tb_c_details WHERE e_id = " & eid & " )" Didnt work ... same problem :(( :(( Any different statment that would give me the same results ??? since i think the error is from the IN phrase .

        0 will always beats the 1.

        modified on Sunday, February 13, 2011 2:51 AM

        1 Reply Last reply
        0
        • S scorp_scorp

          Dear All, Am getting sytex error , Missing operator on the following: sqls = "SELECT c_number, c_description, c_scope, c_category, c_type FROM tb_c WHERE c_scope = " & scope & " AND c_number In select c_number FROM tb_c_details WHERE e_id = " & eid set rst = db.openrecordset (sqls) Cant find any missing operator :~ , also i used a msgbox to show sqls , the statement is perfect. Helpppp !!! :(

          0 will always beats the 1.

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #4

          If you alreasy corrected the in clause, are the scope and eid variables containing character values? If theay are they should be between ''. You could also post the contents of the sqls variable in order to see what's the actual statement that's executed against the database.

          The need to optimize rises from a bad design.My articles[^]

          S 1 Reply Last reply
          0
          • W Wendelius

            If you alreasy corrected the in clause, are the scope and eid variables containing character values? If theay are they should be between ''. You could also post the contents of the sqls variable in order to see what's the actual statement that's executed against the database.

            The need to optimize rises from a bad design.My articles[^]

            S Offline
            S Offline
            scorp_scorp
            wrote on last edited by
            #5

            scope is a string and eid is a int. dim scope as string dim eid as integer scope = CStr(Forms![report_testin]![Combo42].Value) eid =Int(Forms![report_testin]![Combo29].Value) ami defining the string sqls wrong??? I also tried to modify sqls to be: sqls = "SELECT distinct c_number, c_description FROM tb_c INNER JOIN tb_c_details ON tb_c.c_number = tb_c_details.c_number WHERE e_id = " & eid It generates another Error: "The specifies Field 'c_number' could refer to more than one table listed in the FROM clause of your sql statement" but it doesnt make sense for me :wtf:

            0 will always beats the 1.

            modified on Sunday, February 13, 2011 4:08 AM

            W 1 Reply Last reply
            0
            • S scorp_scorp

              scope is a string and eid is a int. dim scope as string dim eid as integer scope = CStr(Forms![report_testin]![Combo42].Value) eid =Int(Forms![report_testin]![Combo29].Value) ami defining the string sqls wrong??? I also tried to modify sqls to be: sqls = "SELECT distinct c_number, c_description FROM tb_c INNER JOIN tb_c_details ON tb_c.c_number = tb_c_details.c_number WHERE e_id = " & eid It generates another Error: "The specifies Field 'c_number' could refer to more than one table listed in the FROM clause of your sql statement" but it doesnt make sense for me :wtf:

              0 will always beats the 1.

              modified on Sunday, February 13, 2011 4:08 AM

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #6

              If scope is a string your statement should be something like

              sqls = "SELECT c_number, c_description, c_scope, c_category, c_type " & _
              FROM tb_c " & _
              WHERE c_scope = '" & scope & "' " & _
              AND c_number IN ( SELECT c_number " & _
              FROM tb_c_details " & _
              WHERE e_id = " & eid & " )"

              Also instead of using literals (concatenated values) in your statement you should use bind variables. This way you're more safe from SQL injections, datatype mismatches, syntax errors etc [addition] Concenring the latter error, you should use aliases in the select portion. Like:

              SELECT distinct tb_c.c_number, tb_c.c_description ...

              The need to optimize rises from a bad design.My articles[^]

              S 1 Reply Last reply
              0
              • W Wendelius

                If scope is a string your statement should be something like

                sqls = "SELECT c_number, c_description, c_scope, c_category, c_type " & _
                FROM tb_c " & _
                WHERE c_scope = '" & scope & "' " & _
                AND c_number IN ( SELECT c_number " & _
                FROM tb_c_details " & _
                WHERE e_id = " & eid & " )"

                Also instead of using literals (concatenated values) in your statement you should use bind variables. This way you're more safe from SQL injections, datatype mismatches, syntax errors etc [addition] Concenring the latter error, you should use aliases in the select portion. Like:

                SELECT distinct tb_c.c_number, tb_c.c_description ...

                The need to optimize rises from a bad design.My articles[^]

                S Offline
                S Offline
                scorp_scorp
                wrote on last edited by
                #7

                Wooooohoooooo :cool::cool::thumbsup: Thanks a lot Mika ,i appriciate , it worked perfect , and thanks for the Addidtional note too ;)

                0 will always beats the 1.

                W 1 Reply Last reply
                0
                • S scorp_scorp

                  Wooooohoooooo :cool::cool::thumbsup: Thanks a lot Mika ,i appriciate , it worked perfect , and thanks for the Addidtional note too ;)

                  0 will always beats the 1.

                  W Offline
                  W Offline
                  Wendelius
                  wrote on last edited by
                  #8

                  No problem :)

                  The need to optimize rises from a bad design.My articles[^]

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups