Results 1 to 15 of 15
  1. #1
    rcerda is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    18

    Display Access Query outside access

    I have created an Application menu, where one of the options is to run a query I have in a form. However, after I am running the application and select the query field and execute it does not show me the results in a new sheet. Is there something else to put on the VBA code to do this.



    Thank you.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    Docmd.openQuery "qsMyQuery"

  3. #3
    rcerda is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    18

    Reply

    Quote Originally Posted by ranman256 View Post
    Docmd.openQuery "qsMyQuery"
    Tried that command but, outside access it does not work

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    Please give us some more info/details. Why would you expect a query to work "outside Access"?
    does not work
    does not tell us anything about your situation. Error? Wrong values?
    Sheets are in spreadsheets/Excel, not Access/database.

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    Sorry but this is as clear as mud.

    Where exactly does outside Access refer to? Excel?
    Do you mean you want to export your query results or run the query from outside Access?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    rcerda is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    18
    Ok, what I mean is that I developed an entry screen through forms, that when I enter the application it hides access. Among the selection buttons of the main menu is to access a Query and once it displays the form, where I enter the field I want to Query, then execute, it does not show the results in a page. However, when I do it in the Access application it works ok. May be it can not be done.

    If you need further explanation let me know and I send you an example.

    Thank you

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    The mud has just got even thicker ...
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Developed an entry screen in what application? What application hides Access? Exactly where did you attempt the suggested code?
    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.

  9. #9
    rcerda is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    18
    Is just a Form which contains buttons that takes you to forms and queries, but it does it with access hiden in the background. The forms work fine, but when I attempt to call the Query it does not show the results.

  10. #10
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    rcerda,

    How about stepping back and telling us in simple, plain English what your application/database is about? No jargon.
    We recognize you are new to Access/database and are anxious to create a database. But, we only know what you tell us about your project. So step back and, using the same language you would use to explain things to an 8 yr old, tell us what you are trying to accomplish. The details of forms and buttons will come later--once we understand what you are trying to accomplish.

    Clarity is critical. Good luck.

  11. #11
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    Quote Originally Posted by rcerda View Post
    Is just a Form which contains buttons that takes you to forms and queries, but it does it with access hiden in the background. The forms work fine, but when I attempt to call the Query it does not show the results.
    Ah. Perhaps I'm beginning to understand.
    I believe you have a database where the form is 'floating on the desktop' with the Access application window, ribbon and navigation pane all hidden.
    In fact similar to this example database I posted here https://www.accessforums.net/showthread.php?t=69856

    If so, you aren't outside Access at all. You just can't see most of it.
    I've not tried to view a query in this setup, but I expect you will have to temporarily make the application window visible to view the query results.
    The link shows how that can be done

    Even if I've now grasped what you want, please answer orange's comment and explain why you want to do this.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  12. #12
    rcerda is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    18
    Quote Originally Posted by ridders52 View Post
    Ah. Perhaps I'm beginning to understand.
    I believe you have a database where the form is 'floating on the desktop' with the Access application window, ribbon and navigation pane all hidden.
    In fact similar to this example database I posted here https://www.accessforums.net/showthread.php?t=69856

    If so, you aren't outside Access at all. You just can't see most of it.
    I've not tried to view a query in this setup, but I expect you will have to temporarily make the application window visible to view the query results.
    The link shows how that can be done

    Even if I've now grasped what you want, please answer orange's comment and explain why you want to do this.
    Yes that is it, thank you. Still I did not make my self very clear. What I meant to say is that Access was hidden but still in there. I hope it works now.

  13. #13
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    I just tested this on my example db by adding another button with code to open a select query.
    Nothing happened

    To get it to work I did the following

    Code:
    Private Sub Command25_Click()    
        SetAccessWindow (SW_SHOWMAXIMIZED) 'shows Access app window
        ShowNavigationPane 
        DoCmd.OpenQuery "qryAccessErrorCodes"
        Me.Visible = False 'need to hide the form as it's a popup
    End Sub
    Now you have a new problem
    You need to reopen the form when you close the query
    I've no idea how you could do that using code as you can't assign code to a query.

    So instead I suggest you do the following.
    Create another continuous or datasheet form with the query results.
    When you click the button on the main form, open the new 'query form' and hide or close the main form
    Then do the reverse when you close the query form
    I use a similar idea to open the Access error codes form in my example

    BUT I have to ask - it it really worth doing this in your case?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  14. #14
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,458
    Just a suggestion for another way. If you don't mind losing sight of the navigation form whilst the query is open

    depends on the design of your navigation form but assuming it is not the access navigation form and is one of your own making ,on your navigation form put a subform somewhere top left but below a 'closequery' button, can be as small as you like, width & height set to 0 if you like. Leave the controlsource blank. This code assumes you are just using the detail section and the header and footer are hidden. if you are using header and footer, replace insideheight with section(0) if the subform is in the detail section, section(1) for the header or section(2) for footer.


    when the user clicks a button to open the query use the following code - replace names with your own

    me.subformname.controlsource="Query." & queryname
    me.subformname.width=insidewidth-me.subformname.left
    me.subformname.height=insideheight-me.subformname.top
    me.subformname.visible=true 'if you had hidden it
    me.btnclosequery.enabled=true 'or use visible


    and in the code in the closequery button would be the reverse
    me.subformname.controlsource=""
    me.subformname.width=0
    me.subformname.height=0
    me.subformname.visible=false 'if you want to hide it
    me.someothercontrol.setfocus 'so you can disable or hide the closequery button
    me.btnclosequery.enabled=false 'or use visible

    Of course you may have space at the bottom or side of your navigation form to show the query in a smaller 'window' In which case change the height and width as required

  15. #15
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    Hi ajax / rcerca

    Following a PM from rcerda, I updated my sample database to include the 2 ways of doing this I mentioned in my previous reply
    a) the bad way - close the main form & open the query - no return route using code
    b) the better way - close the main form & open a new form containing the query results - close that to return to the main form

    If you are interested, compare what I did with your suggestions

    The last 2 buttons are the ones related to this thread
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 2
    Last Post: 02-19-2017, 03:14 PM
  2. Replies: 2
    Last Post: 06-24-2015, 02:38 PM
  3. Replies: 6
    Last Post: 10-30-2012, 11:36 AM
  4. How to display RTF field properly in Access Query
    By Linda1234 in forum Code Repository
    Replies: 0
    Last Post: 09-26-2012, 12:43 PM
  5. Display Access Query in Web Page
    By CarlV in forum Access
    Replies: 3
    Last Post: 09-21-2011, 12:57 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