Allow users to work on 1 form at a time

  • Thread starter Thread starter Danie
  • Start date Start date
Danie

Will depend on which version of Access you are using...

Generically, you'll have a single form, maximized, showing at any one time.

And you'll want to use a custom ribbon/menu, to prevent them from using the
built-in Access functions directly.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Dont give them the user interface to do it. i.e. if they are opened from a
command button, disable the command button if some other form is open.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
Danie said:
How do I prevent a user from opening 2 different forms?

Thanks,
Danie

I really simple and easy way is to build a nice startup form. In that form,
the users can then click on a button to launch another form.

If you open up the forms in design mode and in the "other" tab, you can set
the form to model.

This setting means that the user will have to close the form they just
opened to then choose another button/selection on your main startup form.

So, the model setting in ms-access can be used to control the user "flow"
and what forms they can or cannot open at a given point in time. So, users
will be forced to close the current form and return to where they came from
when you do this.
 
Albert D. Kallal said:
I really simple and easy way is to build a nice startup form. In that form,
the users can then click on a button to launch another form.

If you open up the forms in design mode and in the "other" tab, you can set
the form to model.

This setting means that the user will have to close the form they just
opened to then choose another button/selection on your main startup form.

So, the model setting in ms-access can be used to control the user "flow"
and what forms they can or cannot open at a given point in time. So, users
will be forced to close the current form and return to where they came from
when you do this.



--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)

I did put my form on "Modal" setting but what is strange is that I can open other forms at the same time. Access should ask to close the current form before opening antother one when it is a modal form, but it's not doing so. Is there another way of preventing a 2 forms that shouldn't be opened together to be opened. My programs are called from a menu so a user can call any form from the menu and have 2 or 3 forms opened at the same time. I want to prevent that.

Thanking you,
Danielle
 
Danie,

I am by no means an expert, but what I did was created a couple macros. I
created one to open forms and one to close forms. From my frontpage I have
several buttons to access different forms. If you go under properities you
can have access run a macro on clicking the a button. In the macros I use
open form and close. Depending on how many forms you have it might be
cumbersome...but it works.
 
Had you followed Albert's instructions, you wouldn't have the problem.

But, If you don't want to change your design interface, Here is a function
that will look for any open forms. It will return false if no forms are open
or true if any are open. Call it from the Open event of all you main forms
(not for subforms)

If AnyFormsOpen Then
Docmd.Quit
End If

Public Function AnyFormsOpen() As Boolean
Dim frm As Object

For Each frm In CurrentProject.AllForms
If frm.IsLoaded Then
AnyFormsOpen = True
Exit For
End If
Next
End Function
 
No, that not what model setting does. What model setting does is means that
the form will have to be closed before you can get back to the previous
form. So, asusmign you have a typical appcaion with a start up form, the
user will simly NOT be able to get back to the startup form (to luanc hter
oforms) UNTILL they close the current form. So, there no prompting here,
they simply can't get at the previous form.
My programs are called from a menu so a user can call any form from the
menu and have 2 or 3 forms opened at the same time. I want to prevent
that.

Ah, ok...you are talking about a custom menu bar then? That is VERY BIG
detail here that's been left out. My solution and suggestion requires that
you are using a startup form, and not custom menus.

So, now that we realize that you using a custom menu, then this becomes more
difficult. The only simple solution here is to I would suggest in this case
that you modify your menu bars or menu code to do CHECK FIRST if other forms
are opened.

The simple way to do this is to place the following in the menu bars
on-action

=MyOpenForm('name of form goes here')

So, modify all of your custom menu bar form buttons to have the above on the
on-action command (make a copy of your database if your new to doing this).

Remember, in the place of 'name of form goes here' you simply place the name
of the form you want to be opened.

And, you place the following code in a public standard code module:

Public Function MyOpenForm(strF As String)

If Forms.Count > 0 Then
MsgBox "you must close open forms before you launch another form"
Exit Function
End If

DoCmd.OpenForm strF

End Function


So, the should work just fine for your case. As mentioned, an alternative
approach would be to not use menus and a main startup form. However, I think
the above approach will be less disruptive to your existing design.
 
Sorry, lets try this with the spell checker!!....




No, that not what model setting does. What model setting does is means that
the form will have to be closed before you can get back to the previous
form. So, assuming you have a typical application with a start up form, the
user will simply NOT be able to get back to the startup form (to launch
other
forms) UNTIL they close the current form. So, there no prompting here,
they simply can't get at the previous form which is being used to
open additional forms.
My programs are called from a menu so a user can call any form from the
menu and have 2 or 3 forms opened at the same time. I want to prevent
that.

Ah, ok...you are talking about a custom menu bar then? That is VERY BIG
detail here that's been left out. My solution and suggestion requires that
you are using a startup form, and not custom menus.

So, now that we realize that you using a custom menu, then this becomes more
difficult. The simple solution here is to that you modify your menu bars or
menu code to do CHECK FIRST if other forms are opened.

The simple way to do this is to place the following in the menu bars
on-action

=MyOpenForm('name of form goes here')

So, modify all of your custom menu bar form buttons to have the above on the
on-action command (make a copy of your database if your new to doing this).

Remember, in the place of 'name of form goes here' you simply place the name
of the form you want to be opened. (remember to use quotes around the form
name as above).

And, you then place the following code in a public standard code module:

Public Function MyOpenForm(strF As String)

If Forms.Count > 0 Then
MsgBox "you must close open forms before you launch another form"
Exit Function
End If

DoCmd.OpenForm strF

End Function


So, the should work just fine for your case. As mentioned, an alternative
approach would be to not use menus and a main startup form. However, I think
the above approach will be less disruptive to your existing design.
 
Thank you for your help
Danie

DevilDog1978 said:
Danie,

I am by no means an expert, but what I did was created a couple macros. I
created one to open forms and one to close forms. From my frontpage I have
several buttons to access different forms. If you go under properities you
can have access run a macro on clicking the a button. In the macros I use
open form and close. Depending on how many forms you have it might be
cumbersome...but it works.
 
Thank you for your help.
Danie

Klatuu said:
Had you followed Albert's instructions, you wouldn't have the problem.

But, If you don't want to change your design interface, Here is a function
that will look for any open forms. It will return false if no forms are open
or true if any are open. Call it from the Open event of all you main forms
(not for subforms)

If AnyFormsOpen Then
Docmd.Quit
End If

Public Function AnyFormsOpen() As Boolean
Dim frm As Object

For Each frm In CurrentProject.AllForms
If frm.IsLoaded Then
AnyFormsOpen = True
Exit For
End If
Next
End Function
 
Albert D. Kallal said:
Sorry, lets try this with the spell checker!!....

Ah, but the spell checker won't catch the word "model" used when you meant
"modal", nor for that matter "lets" instead of "let's". <eg>
 
Dirk Goldgar said:
Ah, but the spell checker won't catch the word "model" used when you meant
"modal", nor for that matter "lets" instead of "let's". <eg>

smile!!...yes, I really must fix this....

and you have great day....ok!!...
 
Danie said:
Albert,

Excuse my ignorance but where do I put a public function?
Thanks,
Danie

Ah, ok....

Simply go the modules tab (I don't know what version you are using). You
then click on new to create a new module.

You can the paste in my code example. When done you should see:

Option Compare Database <-- this part should already
-- appear..don't re-paste this


Public Function MyOpenForm(strF As String)

If Forms.Count > 0 Then
MsgBox "you must close open forms before you launch another form"
Exit Function
End If

DoCmd.OpenForm strF

End Function

So, you paste in the above code (the function part).
Then in the menu bar hit the save button.

It will prompt you for a module name. Lets just call it basForms

You can now close the code module.

Your menu buttons should work now. (just change one for the on-action and
test it). Once it get one menu option working, then you can change all
others.

As mentioned, I bumped send...and did spell check the other post..but, no
big worries....
 
Albert,
Thanks for your help.

What do you mean by the paragraph below and how do I change an on-action.

Your menu buttons should work now. (just change one for the on-action and
test it). Once it get one menu option working, then you can change all
others.

Thanks,
Danie
 
Danie said:
Albert,
Thanks for your help.

What do you mean by the paragraph below and how do I change an on-action.

Your menu buttons should work now. (just change one for the on-action and

Right click on your custom menu bar, and select one particular button that
open a form and right click on that menu button and display the proprieties
for that particular option in the menu bar. There is a on-action setting
for each button. That on-action setting allows you to create a button that
runs code in a form, or a code module. In this case we built a custom bit of
VBA code (in that module) that will open a form for us, but ALSO CHECK if
other forms are already opened (and, if other forms are opened, then our
code does NOT allow the form to open...). As I said, you only want to test
this on one button until you get it working and THEN change all other
buttons.....

So, once you changed the one button with the on-action, then open another
form, and then try our button....it should not allow the form to open. And,
test the reverse. Close all forms...and then test our one button. If this
works, then you home free, and can then go and modify all of the other menu
buttons that opens forms..... (so, just modify one button for now untill
this works....you don't want to modify a whole bunch of buttons and then
find out this does not work).
 
Back
Top