Solved

how can i change a forms view from normal to datasheet programatically?

Posted on 2014-09-04
4
213 Views
Last Modified: 2014-09-07
Hi Experts,
I have a sub form that users would like to view it in both ways, meaning in datasheet view by default, but should have the option to switch to normal form view, now I am trying to avoid creating an extra form, is there a way to code this by a click of a button?
When I try running the code me.SubForm.Form.CurrentView=0, I get an error saying "This property is read-only and can't be set"
0
Comment
Question by:bfuchs
[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
  • 3
4 Comments
 
LVL 40

Accepted Solution

by:
als315 earned 500 total points
ID: 40305184
Look at sample
DBView.accdb
0
 
LVL 4

Author Comment

by:bfuchs
ID: 40308833
Hi als315,

Thanks for replying,

I just got a chance to test this in my environment (access 2000), and it says "acCmdSubformFormView" this is not a defined type.

I tried the following
    If Me.subForm1.Form.CurrentView = 1 Then
        Me.subForm1.SetFocus
        DoCmd.RunCommand 108
        btn0.Caption = "Form view"
    Else
        Me.subForm1.SetFocus
        DoCmd.RunCommand 462
        btn0.Caption = "Datasheet view"
    End If

Open in new window


And the first part did well, however the else part (462) is giving me an error "You cancelled the previous command", any idea how to overcome this problem?

Thanks,
Ben
0
 
LVL 4

Author Comment

by:bfuchs
ID: 40308883
I've requested that this question be closed as follows:

Accepted answer: 0 points for bfuchs's comment #a40308833

for the following reason:

Never mind, I got my answer in link below, thanks for pointing me to the right direction.

http://www.experts-exchange.com/Database/MS_Access/Q_23949961.html
0
 
LVL 4

Author Closing Comment

by:bfuchs
ID: 40308884
Never mind, I got my answer in link below, thanks for pointing me to the right direction.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…

615 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