Results 1 to 4 of 4
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    VBA To Check If Query Exists If Does Rename


    I need to check a database and see if 4 queries exist
    Query1
    Query2
    Query3
    Query4

    If those queries exist I want to rename them to Query1_Bad, Query2_Bad, Query3_Bad, Query4_Bad. How could I achieve this in vba?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    How else would I do it w/o VBA? Those links show how to find out if a query already exists - that part I am comfy with. I wasn't sure how to rename the query if it does exist. Using the top link as an example if DoesQryExist = True how do I then change the name of the query?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    I would just manually change the query name in the Navigation pane.

    I don't know if query name can be changed. The query can be copied with a new name then the original can be deleted.
    Explore DoCmd.CopyObject

    Review http://msdn.microsoft.com/en-us/libr...ffice.12).aspx
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Check to see if record already exists
    By zipaway in forum Programming
    Replies: 4
    Last Post: 06-05-2014, 09:16 AM
  2. Replies: 3
    Last Post: 11-26-2013, 03:40 PM
  3. Replies: 1
    Last Post: 03-21-2013, 02:14 PM
  4. Check if record exists, Check Number
    By burrina in forum Forms
    Replies: 9
    Last Post: 01-06-2013, 03:49 PM
  5. How to check if Table already exists
    By riaarora in forum Access
    Replies: 1
    Last Post: 08-12-2012, 09:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums