Runtime Error5 :Invalid Procedure Call

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Garimella
    New Member
    • Jan 2007
    • 9

    Runtime Error5 :Invalid Procedure Call

    When i'm trying to exute a piece of code it's giving this error. Please help me on this. i'm in desperate need of this.
    Code snippet:

    dim rst as recordset
    dim db as database

    Set rst = db.OpenRecordse t("select * from qrySelect",dbOp enSnapshot)
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32634

    #2
    At this point db is set to Nothing.
    Try using CurrentDB.OpenR ecordset or setting db first.

    Comment

    • MMcCarthy
      Recognized Expert MVP
      • Aug 2006
      • 14387

      #3
      Firstly check that the Microsoft DAO library is ticked on the references list. You will find this on the Tools menu in the VB Editor window.

      Then the code is as follows:

      Code:
      Dim rst As Recordset
      Dim db As DAO.Database
      
      Set db = CurrentDB
      Set rst = db.OpenRecordset("select * from qrySelect",dbOpenSnapshot)

      Comment

      • Garimella
        New Member
        • Jan 2007
        • 9

        #4
        hi

        This is related to your suggestion for Invalid procedure call in ms access. I tried by setting it as a new datbase but it's giving an error ' wrong usage of New keyword'. here is the snipet(original ) of the code used. please let me know where to modify.

        Code:
        Dim db As Database
        Dim rst As Recordset
        
        Set db = DBEngine(0)(0)
        
        Set rst = db.OpenRecordset("select * from qrySelect_CostDifferences", dbOpenSnapshot)
        Please help me on this.

        regards,
        garimella
        Last edited by NeoPa; Jan 18 '07, 10:50 PM. Reason: Tags

        Comment

        • MMcCarthy
          Recognized Expert MVP
          • Aug 2006
          • 14387

          #5
          Originally posted by Garimella
          hi

          This is related to your suggestion for Invalid procedure call in ms access. I tried by setting it as a new datbase but it's giving an error ' wrong usage of New keyword'. here is the snipet(original ) of the code used. please let me know where to modify.

          Code:
          Dim db As Database
          Dim rst As Recordset
          
          Set db = DBEngine(0)(0)
          
          Set rst = db.OpenRecordset("select * from qrySelect_CostDifferences", dbOpenSnapshot)
          Please help me on this.

          regards,
          garimella
          garimella

          I used Set db = CurrentDB not DBEngine(0)(0)

          Comment

          • Garimella
            New Member
            • Jan 2007
            • 9

            #6
            Hi

            I tried db=CurrentDb(), but it didn't work it's still giving that error. I've checked the project references, they are fine. This was running fine until Jan 10th. I don't why this started giving this error. I'm trying to run this query manually, not from the code, even then it's giving the same error. I've been trying to fix it for the last 10days but i couldn't, Please help me if there are any other things that does cause this error.

            Regards,
            Garimella

            Comment

            • MMcCarthy
              Recognized Expert MVP
              • Aug 2006
              • 14387

              #7
              Originally posted by Garimella
              Hi

              I tried db=CurrentDb(), but it didn't work it's still giving that error. I've checked the project references, they are fine. This was running fine until Jan 10th. I don't why this started giving this error. I'm trying to run this query manually, not from the code, even then it's giving the same error. I've been trying to fix it for the last 10days but i couldn't, Please help me if there are any other things that does cause this error.

              Regards,
              Garimella
              Check that qrySelect exists as a query and check the spelling of the query.

              Exactly which line is the code stopping at?

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32634

                #8
                Originally posted by Garimella
                Hi

                I tried db=CurrentDb(), but it didn't work it's still giving that error. I've checked the project references, they are fine. This was running fine until Jan 10th. I don't why this started giving this error. I'm trying to run this query manually, not from the code, even then it's giving the same error. I've been trying to fix it for the last 10days but i couldn't, Please help me if there are any other things that does cause this error.

                Regards,
                Garimella
                If it doesn't work for you when running it manually, when it did before (I assume), then there is something wrong.
                You could try posting the SQL of the query here for a quick checkover, but it may well be an issue not directly related to your project.

                Comment

                • MMcCarthy
                  Recognized Expert MVP
                  • Aug 2006
                  • 14387

                  #9
                  Originally posted by Garimella
                  Hi

                  I tried db=CurrentDb(), but it didn't work it's still giving that error. I've checked the project references, they are fine. This was running fine until Jan 10th. I don't why this started giving this error. I'm trying to run this query manually, not from the code, even then it's giving the same error. I've been trying to fix it for the last 10days but i couldn't, Please help me if there are any other things that does cause this error.

                  Regards,
                  Garimella
                  Sorry Garimella

                  Didn't read the last part of this post properly. It sounds like the problem exists in the query rather than the code. Open the query in design view then change the view to sql and copy and paste code here.

                  Mary

                  Comment

                  Working...