Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Changing Forms CurrentView Property Using VBA

Posted on 2004-10-26
Medium Priority
Last Modified: 2008-02-01

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!
Question by:Painfree888
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
  • 2
LVL 39

Expert Comment

ID: 12413561
Why do you want to open in Design View?

DoCmd.OpenForm FormName:="FormB", View:=acDesign


Author Comment

ID: 12413733


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.
LVL 39

Accepted Solution

stevbe earned 525 total points
ID: 12413854
ok ... so check to see if the form is open and then close it and reopen in design view ... are you also opening it hidden?

If SysCmd(acSysCmdGetObjectState, acForm, "FormB") <> 0 Then
    'save and close any pending changes
    DoCmd.Close acForm, "FromB", acSaveYes
End If

'reopen in hidden design mode.
DoCmd.OpenForm FormName:="FormB", _
               View:=acDesign, _


Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

610 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