Solved

toggle subform List/Datasheet via VBA

Posted on 2006-07-10
6
1,048 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

829 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