Solved

Changing Forms CurrentView Property Using VBA

Posted on 2004-10-26
879 Views
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!
0
Question by:Painfree888
    3 Comments
     
    LVL 39

    Expert Comment

    by:stevbe
    Why do you want to open in Design View?

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

    Steve
    0
     
    LVL 5

    Author Comment

    by:Painfree888

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

    Accepted Solution

    by:
    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, _
                   WindowMode:=acHidden

    Steve
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: MongoDB Object-Document Mapper for NodeJS

    NodeJS (JavaScript on the server) is awesome, but some developers get confused about NoSQL when it comes to working in Node with MongoDB (NoSQL database). Do you need a better explanation of how to use Node.js with MongoDB? The most popular choice is the Mongoose library.

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    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…

    846 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

    10 Experts available now in Live!

    Get 1:1 Help Now