Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

toggle subform List/Datasheet via VBA

Posted on 2006-07-10
6
Medium Priority
?
1,073 Views
Last Modified: 2008-09-15
I want to place a toogle-button on the mainform to toggle the subform views.
How can I advise the form to switch the view via VBA?
Chris
0
Comment
Question by:chriswies
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17071597
You can try this

Me.mysubform.form.CurrentView = myviewno

where mysubform = name of your subform
and myviewno is a number to identify what view u want

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17071605
DesignView is view number 0
Form View is 1
Datashee view is 2

ok, it seems CurrentView is a readonly property, so Im thinking u have to open form in Design mode, then change view, then reopen

0
 
LVL 54

Expert Comment

by:nico5038
ID: 17071712
A non-code solution would be to use a tab control with a subform per page and let the tabs work as "toggle button"

Nic;o)
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 65

Accepted Solution

by:
rockiroads earned 1000 total points
ID: 17072188
chriswies

try this

say you had a button on your mainform called cmdToggleView

private sub cmdToggleView_Click

    Me.mysubform.SetFocus
    If Me.mysubform.Form.CurrentView = 1 Then DoCmd.RunCommand acCmdSubformDatasheetView Else DoCmd.RunCommand acCmdSubformFormView

end sub


set focus to subform called  mysubform
if current view is form view then change to datasheet else change to form
0
 
LVL 39

Expert Comment

by:stevbe
ID: 17077116
If I remember correctly you don't need to do the test the CurrentView as setting to acCmdSubformDatasheetView will actually toggle between the 2 view types for you.
0
 
LVL 2

Expert Comment

by:Chi Is Current
ID: 21250748
Sweet solution!  Thanks!!!  Jacob
0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question