Cannot jump to variable definition

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • teddysnips@hotmail.com

    Cannot jump to variable definition

    I've been asked to take over maintenance of a database. The client
    has also requested that I split the database into Front End/Back End.
    I've just taken delivery of the code and I've run it and it all seems
    to work well. The code contains a function to create, copy and delete
    queries on the fly. For these all to be available to all users I have
    taken a look at the current code to do the copying.

    And I've run up against a weird problem. There is a line in the code:

    DoCmd.CopyObjec t , TempString, acQuery, QryID

    The definition for QryID is not in the function, nor in the form's
    module, so I right-clicked on it and selected "Definition ". This
    produces a message that states:

    "Cannot jump to 'QryID' because it is in the library 'C:\Projects
    \ThisProject\Th isDatabase.mdb' which is not currently referenced."

    Needless to say, I am working in 'C:\Projects\Th isProject
    \ThisDatabase.m db. I've looked in Tools, References and there are no
    missing references. I've tried adding a reference and recompiling and
    no luck. I did notice that the name of the database in the properties
    pane when selecting the top node in the Project Explorer in the Code
    window was Access9.mdb, but I've changed it to ThisDatabase.md b and
    still the same error.

    Thoughts?

    Edward
  • Salad

    #2
    Re: Cannot jump to variable definition

    teddysnips@hotm ail.com wrote:
    I've been asked to take over maintenance of a database. The client
    has also requested that I split the database into Front End/Back End.
    I've just taken delivery of the code and I've run it and it all seems
    to work well. The code contains a function to create, copy and delete
    queries on the fly. For these all to be available to all users I have
    taken a look at the current code to do the copying.
    >
    And I've run up against a weird problem. There is a line in the code:
    >
    DoCmd.CopyObjec t , TempString, acQuery, QryID
    >
    The definition for QryID is not in the function, nor in the form's
    module, so I right-clicked on it and selected "Definition ". This
    produces a message that states:
    >
    "Cannot jump to 'QryID' because it is in the library 'C:\Projects
    \ThisProject\Th isDatabase.mdb' which is not currently referenced."
    >
    Needless to say, I am working in 'C:\Projects\Th isProject
    \ThisDatabase.m db. I've looked in Tools, References and there are no
    missing references. I've tried adding a reference and recompiling and
    no luck. I did notice that the name of the database in the properties
    pane when selecting the top node in the Project Explorer in the Code
    window was Access9.mdb, but I've changed it to ThisDatabase.md b and
    still the same error.
    >
    Thoughts?
    >
    Edward
    What is the value of TempString and what is the value of QryID? Is
    QryID passed to the function or is it assigned a value like
    QryID = "SomeTableOrQue ryName"

    Here's an example from help.
    DoCmd.CopyObjec t, "Employees Copy", acTable, "Employees"

    Comment

    • teddysnips@hotmail.com

      #3
      Re: Cannot jump to variable definition

      On 2 Jun, 15:34, Salad <o...@vinegar.c omwrote:
      [...]
      >
      What is the value of TempString and what is the value of QryID?  Is
      QryID passed to the function or is it assigned a value like
              QryID = "SomeTableOrQue ryName"
      >
      Here's an example from help.
      DoCmd.CopyObjec t, "Employees Copy", acTable, "Employees"- Hide quoted text-
      The values are irrelevant. I'm just trying to find out where QryID is
      declared. It's used in the function and elsewhere in the code behind
      the form, but I can't find where it's declared. My current suspicion
      is that it's actually a hidden control on the form's design surface,
      and the developer hasn't prepended it with the Me keyword.

      Edward

      Comment

      • lyle fairfield

        #4
        Re: Cannot jump to variable definition

        Let's compare your line and Access Help's example

        Yours:
        DoCmd.CopyObjec t , TempString, acQuery, QryID

        It seems QryId must be "a string expression that's the valid name of
        an object of the type selected by the sourceobjecttyp e argument."

        Access Example:
        DoCmd.CopyObjec t, "Employees Copy", acTable, "Employees"

        Let's check in Northwinds;
        DoCmd.CopyObjec t , "new query", acQuery, "Inventory" - works
        DoCmd.CopyObjec t , "new query", acQuery, Inventory - error:
        Compile error:
        Expected variable or procedure, not module

        Somewhere in some type library VBA has an object named Inventory and
        it's a module, and VBA expects a string in the place Inventory is
        being used (or a function [procedure] the returns a string, so it
        can't use a module.

        When I ask for the definition of Inventory it opens and shows the
        Module called "Inventory" , not the Query named "Inventory"

        So what if it said it points to the something in the Library DB
        Esmerelda. That would mean that at sometime somewhere there was a
        Library DB named Library Esmerelda referenced by this DB and that the
        type library still thinks this Library is still pertinent. But in your
        case the Library is the DB itself. Perhaps, in days gone by, this DB
        was a Library servicing another DB and VBA got confused. VBA often
        gets confused. A recompile may de-confuse VBA.

        But you can't do a recompile while QryId is undefined.

        So what to do?

        If you can see what string QryID is supposed to be, you have only to
        declare QryId and point it at the string.

        Then recompile. That may lead you to other problems.

        If you can't see what string it is, you could comment out the line and
        recompile and see where that leads and tell us.

        BTW, I'm trying to imagine a situation where one would want to write a
        utility to copy queries, but I can't. IMO If you have a crap db, no
        amount of bandaiding will make it a good db. Start Over.




        On Jun 2, 8:13 am, teddysn...@hotm ail.com wrote:
        I've been asked to take over maintenance of a database.  The client
        has also requested that I split the database into Front End/Back End.
        I've just taken delivery of the code and I've run it and it all seems
        to work well.  The code contains a function to create, copy and delete
        queries on the fly.  For these all to be available to all users I have
        taken a look at the current code to do the copying.
        >
        And I've run up against a weird problem.  There is a line in the code:
        >
        DoCmd.CopyObjec t , TempString, acQuery, QryID
        >
        The definition for QryID is not in the function, nor in the form's
        module, so I right-clicked on it and selected "Definition ".  This
        produces a message that states:
        >
        "Cannot jump to 'QryID' because it is in the library 'C:\Projects
        \ThisProject\Th isDatabase.mdb' which is not currently referenced."
        >
        Needless to say, I am working in 'C:\Projects\Th isProject
        \ThisDatabase.m db.  I've looked in Tools, References and there are no
        missing references.  I've tried adding a reference and recompiling and
        no luck.  I did notice that the name of the database in the properties
        pane when selecting the top node in the Project Explorer in the Code
        window was Access9.mdb, but I've changed it to ThisDatabase.md b and
        still the same error.
        >
        Thoughts?
        >
        Edward

        Comment

        • edwardwill@googlemail.com

          #5
          Re: Cannot jump to variable definition

          On Jun 2, 5:37 pm, lyle fairfield <lyle.fairfi... @gmail.comwrote :
          Let's compare your line and Access Help's example
          >
          Yours:
          DoCmd.CopyObjec t , TempString, acQuery, QryID
          >
          It seems QryId must be "a string expression that's the valid name of
          an object of the type selected by the sourceobjecttyp e argument."
          >
          Access Example:
          DoCmd.CopyObjec t, "Employees Copy", acTable, "Employees"
          >
          Let's check in Northwinds;
          DoCmd.CopyObjec t , "new query", acQuery, "Inventory" - works
          DoCmd.CopyObjec t , "new query", acQuery, Inventory - error:
          Compile error:
          Expected variable or procedure, not module
          >
          Somewhere in some type library VBA has an object named Inventory and
          it's a module, and VBA expects a string in the place Inventory is
          being used (or a function [procedure] the returns a string, so it
          can't use a module.
          >
          When I ask for the definition of Inventory it opens and shows the
          Module called "Inventory" , not the Query named "Inventory"
          >
          So what if it said it points to the something in the Library DB
          Esmerelda. That would mean that at sometime somewhere there was a
          Library DB named Library  Esmerelda referenced by this DB and that the
          type library still thinks this Library is still pertinent. But in your
          case the Library is the DB itself. Perhaps, in days gone by, this DB
          was a Library servicing another DB and VBA got confused. VBA often
          gets confused. A recompile may de-confuse VBA.
          >
          But you can't do a recompile while QryId is undefined.
          >
          So what to do?
          >
          If you can see what string QryID is supposed to be, you have only to
          declare QryId and point it at the string.
          >
          Then recompile. That may lead you to other problems.
          >
          If you can't see what string it is, you could comment out the line and
          recompile and see where that leads and tell us.
          >
          BTW, I'm trying to imagine a situation where one would want to write a
          utility to copy queries, but I can't. IMO If you have a crap db, no
          amount of bandaiding will make it a good db. Start Over.
          I've found out what QryID is - it's a text box on a subform. There is
          a good business reason for the utility to copy queries, believe it or
          not. Thanks to all for the help.

          Edward

          Comment

          • Larry Linson

            #6
            Re: Cannot jump to variable definition

            Just as a matter of interest, if you can do so without revealing company
            confidential information, I'd be eager to learn the good business reason for
            copying queries.

            Almost all valid business needs can be satisfied in multiple ways in
            Access... so there might just be another way to accomplish the purpose that
            is safer, or easier.

            By the way, consistent use of a good naming convention might have made
            finding QryID easier. "txtQryID", in my apps, would immediately be
            identified as a Text Box, and "strQryID" as a string variable. A
            widely-accepted naming convention in the Access world is the Reddick Naming
            Convention, which you'll find documented at
            http://www.xoc.net/standards/default.asp.

            Larry Linson
            Microsoft Office Access MVP

            <edwardwill@goo glemail.comwrot e in message
            news:89e1694e-53a7-4aba-9682-07d9cb992f74@s5 0g2000hsb.googl egroups.com...
            On Jun 2, 5:37 pm, lyle fairfield <lyle.fairfi... @gmail.comwrote :
            Let's compare your line and Access Help's example
            >
            Yours:
            DoCmd.CopyObjec t , TempString, acQuery, QryID
            >
            It seems QryId must be "a string expression that's the valid name of
            an object of the type selected by the sourceobjecttyp e argument."
            >
            Access Example:
            DoCmd.CopyObjec t, "Employees Copy", acTable, "Employees"
            >
            Let's check in Northwinds;
            DoCmd.CopyObjec t , "new query", acQuery, "Inventory" - works
            DoCmd.CopyObjec t , "new query", acQuery, Inventory - error:
            Compile error:
            Expected variable or procedure, not module
            >
            Somewhere in some type library VBA has an object named Inventory and
            it's a module, and VBA expects a string in the place Inventory is
            being used (or a function [procedure] the returns a string, so it
            can't use a module.
            >
            When I ask for the definition of Inventory it opens and shows the
            Module called "Inventory" , not the Query named "Inventory"
            >
            So what if it said it points to the something in the Library DB
            Esmerelda. That would mean that at sometime somewhere there was a
            Library DB named Library Esmerelda referenced by this DB and that the
            type library still thinks this Library is still pertinent. But in your
            case the Library is the DB itself. Perhaps, in days gone by, this DB
            was a Library servicing another DB and VBA got confused. VBA often
            gets confused. A recompile may de-confuse VBA.
            >
            But you can't do a recompile while QryId is undefined.
            >
            So what to do?
            >
            If you can see what string QryID is supposed to be, you have only to
            declare QryId and point it at the string.
            >
            Then recompile. That may lead you to other problems.
            >
            If you can't see what string it is, you could comment out the line and
            recompile and see where that leads and tell us.
            >
            BTW, I'm trying to imagine a situation where one would want to write a
            utility to copy queries, but I can't. IMO If you have a crap db, no
            amount of bandaiding will make it a good db. Start Over.
            I've found out what QryID is - it's a text box on a subform. There is
            a good business reason for the utility to copy queries, believe it or
            not. Thanks to all for the help.

            Edward


            Comment

            • teddysnips@hotmail.com

              #7
              Re: Cannot jump to variable definition

              On 3 Jun, 15:36, "Larry Linson" <boun...@localh ost.notwrote:
              Just as a matter of interest, if you can do so without revealing company
              confidential information, I'd be eager to learn the good business reason for
              copying queries.
              >
              Almost all valid business needs can be satisfied in multiple ways in
              Access... so there might just be another way to accomplish the purpose that
              is safer, or easier.
              >
              By the way, consistent use of a good naming convention might have made
              finding QryID easier. "txtQryID", in my apps, would immediately be
              identified as a Text Box, and "strQryID" as a string variable. A
              widely-accepted naming convention in the Access world is the Reddick Naming
              Convention, which you'll find documented athttp://www.xoc.net/standards/default.asp.
              You're actually preaching to the choir - as I mentioned in my original
              post I've been asked to take over the maintenance of this database.
              It's not feasible to rename objects as I would name them (although the
              tables are named with the tbl- prefix, which is a start). As an
              aside, our company has decided to move away from the naming
              convention, which is a right royal PITA when using SQL Server, as
              prepending all your user objects with tbl- for tables, vw- for views,
              stp- or sp- for SPROCs, fn- for UDFs means that they're all in one
              place in the window.

              But I digress. The reason for copying queries is because the database
              is used by a small number of people of differing technical ability who
              wish to share information in a quick and dirty way. Let's say you
              decide you want a query that shows all customers who purchased widgets
              in May 2007, the application allows you to do this and to save the
              query. Now let's say that you want to know who purchased widgets in
              June 2007, you just copy the query, rename it, and amend it to show
              the new date range.

              NB: I WOULDN'T HAVE DONE IT THIS WAY!!! But I didn't develop it, and
              there's no budget to back out this modus operandi and do it
              differently. Actually, it's one of the very few lacunae in Access -
              the ability to build queries on the fly for non-techie users in code
              (it does it ok using the wizards).

              Edward

              Comment

              Working...