Results 1 to 15 of 15
  1. #1
    MDAO is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    20

    Default View of a Query

    Hi all,

    I know similar questions have been asked, but I guess I am having a somewhat different one.
    I am trying to open a query in the pivot table view by default, so I went to the property table of the query in the design view and changed the default view to pivot table. When I open it on the column on the left, it works perfectly fine.

    So now what I am trying to do is that I created a form, and put a button on the form. I would like to open the query from this form when I click on that button. However, when I open the query this way, it opens in its ordinary view.

    Does anyone of a solution to the issue above, please?

    Thanks a lot!



    Mike

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Open form in Pivot View instead of query.
    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
    MDAO is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    20
    Quote Originally Posted by June7 View Post
    Open form in Pivot View instead of query.
    Thank you! But how do you do that?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Bind form to data. Set the form DefaultView property or use the PivotView option from ribbon.
    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.

  5. #5
    MDAO is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    20
    Thank you. I have tried it. But the same problem arose. When I opened it in the list on the left, it works. But when I open it through a form, it goes back to the form view.
    PS: I ve tried the defaultview property method. I don't know what it means by "from ribbon".
    Sorry, I know so little.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Access 2007 introduced the control 'ribbon', no longer a menu bar. The Home tab on the ribbon has a Views section. Can manually choose the view you want the form to display in.

    What is the code when you 'open it through a form'? Macro or VBA? It can override the DefaultView setting.
    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.

  7. #7
    MDAO is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    20
    Quote Originally Posted by June7 View Post
    Access 2007 introduced the control 'ribbon', no longer a menu bar. The Home tab on the ribbon has a Views section. Can manually choose the view you want the form to display in.

    What is the code when you 'open it through a form'? Macro or VBA? It can override the DefaultView setting.
    Oh, that's called "ribbon". Yea, I knew I could change the view using that button in the ribbon, but I would like to open it by clicking a button in a form, so that users who know nothing about Access can see the pivot table once they open it.

    I created a form, and put a button on it. When I right-click the button, and in the "build event" window is the code:

    Private Sub PCFNAT_OPENQUERY_Click()
    On Error GoTo Err_PCFNAT_OPENQUERY_Click


    Dim stDocName As String


    stDocName = ChrW(80) & ChrW(67) & ChrW(70) & ChrW(95) & ChrW(22283) & ChrW(-31287) & ChrW(20998) & ChrW(20296)
    DoCmd.OpenQuery stDocName, acNormal, acEdit


    Exit_PCFNAT_OPENQUERY_Click:
    Exit Sub


    Err_PCFNAT_OPENQUERY_Click:
    MsgBox Err.Description
    Resume Exit_PCFNAT_OPENQUERY_Click

    End Sub



    I guess you are right about the default view setting being overridden. Is there a way to fix it?

    Thanks a lot.
    I greatly appreciate it.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Instead of acNormal, try acPivotTable.

    You are still opening a query and not form or report. Usually best not to have users interact with tables and queries.

    Why are you using ChrW() to construct name? Just type the name within quote marks.
    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
    MDAO is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    20
    Quote Originally Posted by June7 View Post
    Instead of acNormal, try acPivotTable.

    You are still opening a query and not form or report. Usually best not to have users interact with tables and queries.

    Why are you using ChrW() to construct name? Just type the name within quote marks.
    I have tried replacing "acNormal" with "acPivotTable," but nothing seems to have changed. Did I do anything wrong?
    I didn't type any of the code there because I don't know how to. I am constructing the whole thing simply using the built-in function. For example, when you put a button there, a window shows up and asks you what you want to do with that button.
    I understand a form is preferred to a query so that users won't mess up with the data. I just didn't know you could make a pivot-table from a form until you told me. Now, I have many databases to work on. So I am thinking maybe I learn the way of opening a query in a pivot-table by default first. After that, I will change the queries to forms one by one.

    CODE:
    Private Sub PCFNAT_OPENQUERY_Click()
    On Error GoTo Err_PCFNAT_OPENQUERY_Click


    Dim stDocName As String


    stDocName = ChrW(80) & ChrW(67) & ChrW(70) & ChrW(95) & ChrW(22283) & ChrW(-31287) & ChrW(20998) & ChrW(20296)
    DoCmd.OpenQuery stDocName, acPivotTable, acEdit


    Exit_PCFNAT_OPENQUERY_Click:
    Exit Sub


    Err_PCFNAT_OPENQUERY_Click:
    MsgBox Err.Description
    Resume Exit_PCFNAT_OPENQUERY_Click

    End Sub

    Thanks!

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Sorry, it is acFormPivotTable. Just pick from the intellisense list when typing the command.
    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.

  11. #11
    MDAO is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    20
    Quote Originally Posted by June7 View Post
    Sorry, it is acFormPivotTable. Just pick from the intellisense list when typing the command.
    It WORKS!!! HAHA thanks a lot.
    Now the query opens in pivot chart by default. Is there a way I can make it open in pivot table?

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Are you opening a query or form?

    Did you see the list of options that intellisense presents when typing the command? They will be slightly different for query and 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.

  13. #13
    MDAO is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    20
    Quote Originally Posted by June7 View Post
    Are you opening a query or form?

    Did you see the list of options that intellisense presents when typing the command? They will be slightly different for query and form.
    I am opening a query. No, I don't see the intellisense list.

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    As you type the DoCmd code, the VBA intellisense popups should show. Do you ever see intellisense popups?

    For form:
    acFormPivotChart
    acFormPivotTable

    For query:
    acViewPivotChart
    acViewPivotTable
    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.

  15. #15
    MDAO is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    20
    Quote Originally Posted by June7 View Post
    As you type the DoCmd code, the VBA intellisense popups should show. Do you ever see intellisense popups?

    For form:
    acFormPivotChart
    acFormPivotTable

    For query:
    acViewPivotChart
    acViewPivotTable
    I don't know why. Maybe, I didn't do everything correctly, so the list didn't show.
    BUT THANKS!
    Now it is working as how I hoped it to be!~

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

Similar Threads

  1. Default form view on startup
    By akhlaq768 in forum Forms
    Replies: 1
    Last Post: 02-07-2012, 09:24 AM
  2. Default View from Switchboard
    By JRINC in forum Forms
    Replies: 3
    Last Post: 10-12-2011, 01:34 PM
  3. How to change default view at launch?
    By seawulf in forum Access
    Replies: 3
    Last Post: 09-04-2011, 12:57 PM
  4. Query default to Pivot Table view
    By Theremin_Ohio in forum Access
    Replies: 1
    Last Post: 03-30-2011, 09:17 AM
  5. Replies: 3
    Last Post: 02-22-2011, 04:50 PM

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