Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Check for the existence of a query ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    What is the command to check for the existence of a query object?

    Thanks, John

  2. #2
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check for the existence of a query ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7

    Hi Hans

    Sounds like the error trap is the way to go.

    I have a Function provided by CodeDisk II - DoesObjectExist(strNameOfObject As String, strAnyTypeOfObject As String) As Boolean

    however it can only be used for "Tables", "Forms", "Reports", "Scripts", or "Modules".

    Why are database container query objects different?

    Thanks, John

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check for the existence of a query ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7

    I don't know what code is behind DoesObjectExist, so I have no idea.

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Check for the existence of a query ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7

    I also do not know what "CodeDisk II" is, but I guess it is using DAO Container and Document objects. From VBA Help for DAO Container Object:
    <hr>Each Database object has a Containers collection consisting of built-in Container objects. Applications can define their own document types and corresponding containers (Microsoft Jet databases only); however, these objects may not always be supported through DAO.

    Some of these Container objects are defined by the Microsoft Jet database engine while others may be defined by other applications. The following table lists the name of each Container object defined by the Microsoft Jet database engine and what type of information it contains.

    Container name Contains information about
    Databases Saved databases
    Tables Saved tables and queries
    Relations Saved relationships
    <hr>
    Note that the Tables Container contains both saved tables and queries. This makes sense from the DB Engine's perspective because you can use either a table or saved query as data source as specified in SQL FROM clause, which is why you can't give the same name to a table and a query in the same database. So it was decided, apparently, to keep them in same document container.

    HTH

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check for the existence of a query ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7

    Hi Mark & Hans

    Mark thanks for the exclamation.

    The following explains CodeDisk

    Calvin answered a few of my posts on this forum a year ago and I followed his link to CodeDisk which I purchased.

    HTH

    John

    ============================
    CodeDisk README.TXT file - 04/1/2000

    Welcome to CodeDisk!

    Published by:

    Calvin Smith
    Software Contracts-R-Us

    WEB URL: http://www.CalvinSmithSoftware.com/c.../sneakpeek.htm

    Internet E-Mail: CodeDiskHelp@Yahoo.com

    Questions and Answers
    =====================

    Q: How do I get support for CodeDisk?
    -------------------------------------------
    A: Write an e-mail message using the e-mail address
    listed above. The CodeDisk team checks and responds
    to e-mail daily.


    Q: What O/S does CodeDisk run in?
    -------------------------------------------
    A: CodeDisk runs on Win9x and NT platforms.


    Q: Will CodeDisk run in multiple screen resolutions?
    ----------------------------------------------------
    A: Yes. CodeDisk was tested in 800x600 and 1024x768 resolutions.


    Q: How can I suggest changes to CodeDisk?
    -------------------------------------------
    A: Write an e-mail message using the e-mail address
    listed above. The CodeDisk team invites suggestions,
    and it helps keep CodeDisk the best you can get. We
    really do listen, and make software changes based on
    personal user input.


    Q: How can I get new modifications to CodeDisk?
    -------------------------------------------
    A: Modifications can be downloaded from:

    http://www.calvinsmithsoftware.com/codedisk/latest.htm


    Q: How can I register CodeDisk?
    -------------------------------------------
    A: With CodeDisk running, pull down the 'Feedback/Register' menu
    and select the "E-mail CodeDisk Team" option. Registering will
    allow the CodeDisk team to send you new changes to CodeDisk and
    inform you about new releases.


    Q: Which version of CodeDisk do I have?
    -------------------------------------------
    A: With CodeDisk running, pull down the 'About' menu
    to see what version you are using.


    Q: How often does the CodeDisk team release new versions?
    ------------------------------------------------
    A: New versions of CodeDisk are released every two years.


    Q: How do I get the latest version?
    ------------------------------------------------
    A: The CodeDisk team will notify you via e-mail
    when new versions are available.


    Known Problems & Application Notes
    ==================================
    * No problems to report after testing in Win9x and NT platforms.

    * CodeDisk is a single user application that runs on
    local drives only (i.e. "C:", "D:", "E:", "F:", or "G:"). If you require
    a multi-user version, please send e-mail to the above
    address. There will be additional costs to consider.

    We hope that you find CodeDisk very useful. Please tell others
    about it.

  6. #6
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check for the existence of a query ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7

    Hi Hans

    QueryExistsLoop works OK, however QueryExistsErrorTrap returns False

    Any thoughts?

    Thanks, John


    ?QueryExistsLoop ("qryUpdateClaimsPulled")
    True

    ?QueryExistsErrorTrap ("qryUpdateClaimsPulled")
    False

    Function QueryExistsErrorTrap(QueryName As String) As Boolean
    Dim strName As String
    On Error Resume Next
    strName = CurrentData.AllQueries(QueryName)
    QueryExistsErrorTrap = (Err = 0)
    End Function

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check for the existence of a query ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7

    <P ID="edit" class=small>(Edited by HansV on 20-Nov-03 14:37. Corrected mistake in second function)</P>Either loop through AllQueries and test if you encounter the name, or try to refer to the object and test if an error occurs.

    1. Loop

    Function QueryExists(QueryName As String) As Boolean
    Dim obj As AccessObject
    For Each obj In CurrentData.AllQueries
    If obj.Name = QueryName Then
    QueryExists = True
    Exit For
    End If
    Next obj
    Set obj = Nothing
    End Function

    2. Error trapping

    Function QueryExists(QueryName As String) As Boolean
    Dim strName As String
    On Error Resume Next
    strName = CurrentData.AllQueries(QueryName).Name ' added
    QueryExists = (Err = 0)
    End Function

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check for the existence of a query ? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7

    Sorry, my mistake. It should have been

    strName = CurrentData.AllQueries(QueryName).Name

    I corrected my original reply.

Posting Permissions

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