Switchboard form closing when I open any other form in design view.

Local time
Today, 10:46
Joined
Feb 28, 2023
Messages
696
Somewhat hard to explain and I don't remember this happening before.

By default, I have code in my database that closes all other forms except a hidden form, the switchboard, or the current form.

Multiform is a public Boolean variable.

So if I call the current form FrmA, the code looks like this:

Code:
Private Sub Form_Activate()
If Multiform = False Then
   Dim intx As Integer
   Dim intCount As Integer
   intCount = Forms.Count - 1
   Screen.MousePointer = 11
    For intx = intCount To 0 Step -1
        If Forms(intx).Name <> "frmA" And Forms(intx).Name <> "frmLogoutTimer" And Forms(intx).Name <> "frmSwitchboard" Then
            DoCmd.Close acForm, Forms(intx).Name
        End If
   Next
   Screen.MousePointer = 1
End If
End Sub

That works fine when I open the form, but I noticed today that if I go to design view - either directly in frmA or from the VB Editor Class Object, the frmSwitchboard closes. If I have timers on, it comes back, so the frmLogoutTimer is NOT closing.

If Multiform is set to True, then the switchboard does not close when I go into design view.

There is no code in Form Load that would close open forms (and if it did, it should work when I view the form as well as when I go into design view.

Any ideas what could cause this?
 
I don't like having multiple forms open at once. I believe it confuses the user. Therefore, in the rare occassions where I do want multiple forms open, I have formA open formB as modal so you can see both but you need to close formB to get back to formA. Therefore I use a different technique. formA uses the OpenArgs argument to pass its name to formB and then makes itself invisble. When formB closes, it opens the calling form by using the value pased in the OpenArgs argument and closes itself.

Here is a sample:

 
For what we do, having mulitple forms open at once is convenient and often preferred.

But this is somewhat different.

The database has two modes. If variable MultiForm is true, any number of forms can be open. If Variable MultiForm is false, then only the current form, the switchboard, and the hidden timer form should be open - but the switchboard and the hidden timer form should always be open.

I discovered something else that might help explain what is happening, although it didn't help me.

I set Multiform to True. Then I opened FrmA. Then I went to do design changes on FrmB. FrmA closed, but the switchboard stayed open - similar to what should happen if Multiform was False.

So it seems like opening one of my forms in design view closes some of the other forms, but not necessarily the switchboard, but I don't see why it is doing that.
 
Isn't this a little moot?
Users will never go into design mode, so it is only an issue for you? And when in design mode, I never expected the db to run as normal.
 
Issue is that I somewhat painted myself into a corner with some of the security protections.

- I have the nav pane disabled on Startup.
- I have the toobar disabled on startup.
- I have a timer on the hidden form to re-open the switchboard if it closes, and it fires every 2 seconds, but I have a button to disable the timers (only for me) - b/c the timers interfere with typing in the VB Editor.

With the above, if the switchboard closes unexpectedly, I have no way to get it back other than closing and re-opening the database.

It's mainly an issue of training myself to open the nav pane before I start doing design work.
 
Issue is that I somewhat painted myself into a corner with some of the security protections.

- I have the nav pane disabled on Startup.
- I have the toobar disabled on startup.
- I have a timer on the hidden form to re-open the switchboard if it closes, and it fires every 2 seconds, but I have a button to disable the timers (only for me) - b/c the timers interfere with typing in the VB Editor.

With the above, if the switchboard closes unexpectedly, I have no way to get it back other than closing and re-opening the database.

It's mainly an issue of training myself to open the nav pane before I start doing design work.
Create a Tempvar/Global boolean and test for that.
Set it if it is you when you login and only do all this security if it is not you.
O look for a text file in a folder, if present, it is you, if not then apply all that security.

I would probably add a field in the user table in case I had someone to help me, so we both would not have issues.
Have you disabled Shift Bypass as well?
 
Create a routine called Dev or something equally simple in a module that undoes all of your security measures and turns the switchboard timer off. Call it from the immediate window as soon as you open the vba window.
 
You probably also want a reset dev procedure; otherwise, you have to close and reopen to go back to testing.

The database has two modes. If variable MultiForm is true, any number of forms can be open. If Variable MultiForm is false,
I'm not sure I really want to know the answer but Why? is it for your convenience because you are having so much trouble getting around your security or is it because some users need to have multiple forms open?

PS, how does the switchboard get closed accidentally? I don't like the idea of having to have a timer to take care of that problem. I would simply find and fix the problem rather than adding a dangerous bandaid.
 
I like @Minty 's suggestion. I'm going to take it to the next level (and pick up Pat's idea). I already have buttons on the switchboard to show/hide the toobar, show/hide the ribbon, turn off the timers. Put I can't get to them if the switchboard is closed. I'm going to add a public variable called Dev Mode and a new Dev Mode/User mode button on the switchboard and a new Admin Module in VBA with two subroutines: EnableDevMode and CancelDevMode.

I'm not sure I really want to know the answer but Why? is it for your convenience because you are having so much trouble getting around your security or is it because some users need to have multiple forms open?
Nothing to do with security. Originally, this database always had multiple forms open. When we were having issues with "garbage" entries in records, I had it close other forms when a new one was opened - in hopes it would reduce errors or limit them to one form - it didn't. Now it a convenient way to switch between any combination of forms.

PS, how does the switchboard get closed accidentally? I don't like the idea of having to have a timer to take care of that problem. I would simply find and fix the problem rather than adding a dangerous bandaid.
Currently, by going to design mode in any other form. I don't know why that happens or how to correct it, which is why I asked here.

Otherwise (not quite accidentally - https://www.access-programmers.co.u...t-click-close-menu.328536/page-2#post-1888241), users COULD right-click on it and close it. I can disable that, but if I do that, it also disables the right-click filter menu on other tabs, and since I disabled datasheet view, that ability is useful - somewhat of a domino effect.
 
Currently, by going to design mode in any other form. I don't know why that happens or how to correct it, which is why I asked here.

Do you have a common object on the forms like a logo in a subform for instance?
That will sometimes cause the other form to close if you open any other form in the design view with the same object on it.
 
Do you have a common object on the forms like a logo in a subform for instance?
BINGO!!! I did recently add a common subform to the switchboard and now that I think about it, I didn't see this error until I did. Now that I know what is causing it, I can live with (or implement your workaround to) the issue!

Thank you!
 
Currently, by going to design mode in any other form. I don't know why that happens or how to correct it, which is why I asked here.
OK. It is only when you are working on the database that it happens. You need to give yourself a way to open the database and bypass the security. You can't have the lock down security keeping you from doing things. Having a form with a timer open while you are modifying objects is a recipe for disaster.
 
Minty's reply #8 is going to fix that. For now, I have separate buttons to disable the timers and Show the nav pane - just need to remember to select them.
 
just need to remember to select them.
The timer shouldn't be there. You need to stop blocking yourself out. The timer is a bandaid and it is dangerous to have it running while you are in design mode but do whatever you want.

Having been burned by timers, I always add code to the forms that have them to turn the timer off when it is me logged in. I log in using my test credentials when I want to test the timer part of the application. In your case, the only reason for the timer is for it to be operable while you are testing. That is dangerous.
 

Users who are viewing this thread

Back
Top Bottom