Results 1 to 7 of 7
  1. #1
    billybeer is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2015
    Posts
    27

    hiding a query after opening a form based on the query

    I have a form that will run a query and open a form that uses that query as a record source. How do I hide the query so that the user only sees the form.



    Thanks.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    This code will close a query
    Code:
    DoCmd.Close acQuery, "YourQueryName"
    Alternatively you could run the query as a SQL statement so it would never actually be opened

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why are you opening query object anyway? Just open the form.
    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.

  4. #4
    billybeer is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2015
    Posts
    27
    opening the query so that the table can be updated. I can close the query but I do that after the update, I just don't want the user to ever see it.

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    opening the query so that the table can be updated. I can close the query but I do that after the update, I just don't want the user to ever see it.
    So as already stated, convert your query to SQL and run that as code from your form - either in the Form_Load event or from a button click event
    The user doesn't need to see anything happen whilst it runs

  6. #6
    billybeer is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2015
    Posts
    27
    Thanks, I will give that a try.

  7. #7
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You can use a saved query... but instead of opening the query use
    Code:
    CurrentDb.Execute "YourQueryName", dbFailOnError

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

Similar Threads

  1. Replies: 3
    Last Post: 07-12-2017, 12:03 PM
  2. Replies: 3
    Last Post: 07-26-2016, 02:12 PM
  3. Replies: 8
    Last Post: 03-21-2014, 04:31 AM
  4. Replies: 7
    Last Post: 07-11-2013, 10:45 AM
  5. Replies: 18
    Last Post: 10-10-2012, 10:10 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