Solved

toggle subform List/Datasheet via VBA

Posted on 2006-07-10
6
1,041 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
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 65

Accepted Solution

by:
rockiroads earned 250 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

770 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