Results 1 to 6 of 6
  1. #1
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419

    Access Macro -

    In Access Macro, when you OpenQuery, you actually run the Query ?

    For example, you already created a Query, so why in Access Macros, do you have it script to OpenQuery, and then Close it again with CloseWindow ?
    Is it to open the query and update it ?



    I can understand why there is CopyObject, because you want to copy the source to a new table and you have these two table set up.

    I don't get why there is OpenQuery (example read only) and then closing it again. Is it to update the query, sorry for reiterating it.

    Thanks !!

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I do not know why, I never use the Open Query method because, AFAIK, it is not available during RunTime.

  3. #3
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    Ok thanks for sharing !! I wonder if we don't use OpenQuery and CloseWindow, would it still work as if we did. :-)

    Trying to do automation with Access Macros.

    Why Access macros allow us to use OpenQuery, then CloseWindow again. Doesn't make much sense to me, unless I think it open the query to update it, and then close it again. :-)

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    It has been a couple months but, I remember seeing a DB that used the RunSQL method from a macro. In VBA, you can use the name of a query object with this method so I would imagine it would be the same for a saved macro object.

    Here is some reference.
    http://msdn.microsoft.com/en-us/libr...ffice.14).aspx

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    I suppose could have code open query, export to Excel or as attachment to email, then close it. I've only had need to program this once.

    Never used CloseWindow method.
    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.

  6. #6
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    OpenQuery isn't very usefull for normal SELECT querys. But it gets very handy for DELETE and UPDATE, especially in combination with defined parameters for the query. The macro designer allows you to fill in the parameters in this case, what allows you to write UPDATE and DELETE queries independent from the place, you are using them (no direct references to form fields for ex.). UPDATE and DELETE queries are executed as you would double click them from the query list. If you don't want the warning methods, you will need to disable warnings first.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-07-2012, 09:19 AM
  2. Replies: 2
    Last Post: 05-05-2012, 02:34 AM
  3. access 2007 macro
    By unit91 in forum Queries
    Replies: 17
    Last Post: 04-19-2012, 02:27 PM
  4. Replies: 0
    Last Post: 01-12-2011, 12:43 PM
  5. Access Macro
    By Gargen in forum Access
    Replies: 0
    Last Post: 09-14-2009, 09:13 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