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
Solved

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

Posted on 2014-09-04
4
209 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 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

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…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

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