[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Changing Forms CurrentView Property Using VBA

Posted on 2004-10-26
3
Medium Priority
?
1,093 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
Comment
Question by:Painfree888
  • 2
3 Comments
 
LVL 39

Expert Comment

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

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

Steve
0
 
LVL 5

Author Comment

by:Painfree888
ID: 12413733

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

Steve
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…

640 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