Stopping symultaneous form use (1 Viewer)

Q

Qoo

Guest
Hiya

I have a DB where the user selects which department he wished to add data for from a main form. At present the user can open all 5 departmental forms simulatneously, however, im trying to make it so that only one department can be open at any one time and when they go to open anew department a msgbox opens.
I have tried using the code i used to use in VB but it doesnt seem to work.
In the departmental buttons i have some code:

private sub cmdtapes_click()

if form_toxic.open = true then
msgbox "Please do not open more than one form at a time"
form_toxic.close
end if

I think it is something to do with the open and close commands and how i am refering to the form in VBA

can any offer any help?
thanks very much

Qoo
 

SilentBreaker

Registered User.
Local time
Today, 12:58
Joined
Aug 7, 2003
Messages
28
Do not need to write VBA to do this. All you need to set the Form's property of Modal set to "Yes" in the Form Design Mode. That means the user cannot open another form until the opened form is closed.

Cheers :)
 

Mile-O

Back once again...
Local time
Today, 12:58
Joined
Dec 10, 2002
Messages
11,316
When opening another form why not make the current form invisible and open the other and use this code to determine if form's are open.


Code:
Public Function IsFormOpen(strFormName As String) As Boolean

    IsFormOpen = (SysCmd(acSysCmdGetObjectState, acForm, strFormName) = acObjStateOpen)
    
End Function
 

Mile-O

Back once again...
Local time
Today, 12:58
Joined
Dec 10, 2002
Messages
11,316
SilentBreaker said:
All you need to set the Form's property of Modal set to "Yes" in the Form Design Mode. That means the user cannot open another form until the opened form is closed.

If you have a modal form it is quite easy to open another form from it.
 

SilentBreaker

Registered User.
Local time
Today, 12:58
Joined
Aug 7, 2003
Messages
28
This is a good stuff, mate. I have used this often, but not this many forms as five forms.

:D
 

SilentBreaker

Registered User.
Local time
Today, 12:58
Joined
Aug 7, 2003
Messages
28
In my MS Access applications, I have no problem with the property of Model set to "Yes".:confused:
 
Q

Qoo

Guest
Just changed the properties of modal to yes and it worked a treat. Will try the code too.... anything to stop those pesky users messing about :D

thanks for the help SilentBreaker and Mile-o-Phile its much appreciated :)

laters

Qoo
 

Mile-O

Back once again...
Local time
Today, 12:58
Joined
Dec 10, 2002
Messages
11,316
But from a modal form it is quite simple to open another form.

Granted, if there is a second form underlying the modal form, the user can't get to that but the modal form itself can open other forms.
 

SilentBreaker

Registered User.
Local time
Today, 12:58
Joined
Aug 7, 2003
Messages
28
Let make it clear. If you have a modal form with a command button and the user click that button to open another modal form. Yes, this does work. But you cannot go back to the previous form until you close the second modal form. Your comments are correct and yes, of course it's a tricky part :D

Cheers :D
 

AncientOne

Senior Citizen
Local time
Today, 12:58
Joined
Mar 11, 2003
Messages
464
you can't open a second modal form if the first one is also a pop-up- can you?
 

Mile-O

Back once again...
Local time
Today, 12:58
Joined
Dec 10, 2002
Messages
11,316
AncientOne said:
you can't open a second modal form if the first one is also a pop-up- can you?

Yep, and the second becomes the modal one until it is closed.
 

Users who are viewing this thread

Top Bottom