Solved

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

Posted on 2014-09-04
4
204 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
  • 3
4 Comments
 
LVL 39

Accepted Solution

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

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 3

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 3

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now