Painfree888
asked on
Changing Forms CurrentView Property Using VBA
OK, have what I hope is an easy question, though I can't seem to figure out how to do it. I have an application, in which are two forms (FormA and FormB). What I would like is to have a button on FormA that, when clicked, will set the currentview of FormB to Design Mode. In other words, I want users to be able to click the button on FormA and have that button click show FormB in Design Mode. Hopefully, that's clear enough. Here is the code I am using to (unsuccessfully) accomplish this (button name is: dButton).
Private Sub dButton_Click()
Forms!FormB.CurrentView = 0 'Set FormB to Design Mode
End Sub
My problem is that when the button is clicked, I get an error message stating that the CurrentView property is read-only and may not be changed. Is this true? If so, how would I accomplish the desired result?
Any and all help would be greatly appreciated. I have allocated 175 points for the answer to this rather annoying question.
As always, thank you!
ASKER
Steve,
My example is a simplified version of what I am and want to do in my app. The form opens in design view because I am creating objects on the form and then displaying them based on which button a user clicks. I have been using the method you describe, OpenForm, but that appears to cause a problem with window spawning. In other words, at a certain point, when the user clicks the button, fifty form windows appear to spawn (they appear down in the task bar - fifty or so instances of the window I am opening in design mode).
So, my thought was, instead of using the OpenForm method, which appears to be causing me problems, instead I would open the form just once and then switch back and forth between normal and design mode. One way I had thought to do this was to set the CurrentView property. Sadly, it is read-only. So, was wondering if there is another way to get a form into design mode without using the OpenForm method.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DoCmd.OpenForm FormName:="FormB", View:=acDesign
Steve