Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

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

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
bfuchs
Asked:
bfuchs
  • 3
1 Solution
 
als315Commented:
Look at sample
DBView.accdb
0
 
bfuchsAuthor Commented:
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
 
bfuchsAuthor Commented:
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
 
bfuchsAuthor Commented:
Never mind, I got my answer in link below, thanks for pointing me to the right direction.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now