the number of open forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear all,

I'd like to control the number of open forms in my database,I'd like to
keep it always one form "other that the dialog boxes" ,so in the task bar I
may see only one icon not many ones.
In other words,in the task bar (where you can find the time,the
language,start button..ecc),if i open more than one form i can see more than
one item in the task bar.So I'd like that,when i open a form, to close all
the other open forms so that i may find only one itemon the task bar.
 
Pietro ha scritto:
Dear all,

I'd like to control the number of open forms in my database,I'd like to
keep it always one form "other that the dialog boxes" ,so in the task bar I
may see only one icon not many ones.
In other words,in the task bar (where you can find the time,the
language,start button..ecc),if i open more than one form i can see more than
one item in the task bar.So I'd like that,when i open a form, to close all
the other open forms so that i may find only one itemon the task bar.


On Load Event's call:

Call CloseAllForms(Me.Name)

This on bas standard:

Public Function CloseAllForms(Optional strForm As String =
vbNullString) As Boolean
'*****************************************************************
'Name : CloseAllForms()
'Purpose : Close all Forms eccept Form.Name passed
'Author : Alessandro Baraldi
'Date : 23 gennaio 2002
'Called by :
'Calls :
'Inputs : Form that must be Open
'Output : True if is OK
'*****************************************************************
On Error GoTo Err_Close
Dim n, x As Integer
n = Forms.count
For x = n - 1 To 0 Step -1
If Forms(x).Name <> strForm Then DoCmd.Close acForm,
Forms(x).Name
Next
CloseAllForms = True

Exit_here:
Exit Function
Err_Close:
CloseAllForms = False
Resume Exit_here
End Function

@Alex
 
Thank you very much Sig. Alessandro
But what do you mean by "Call"
I need also an explaination for the function you wrote ,whre should put the
forms' name ?
 
If you don't want more then one window to appear in the taskbar, then you
can change this setting.


tools->options->view tab

Un-check the [ ] windows in task bar.

If you do the above, then you only see one window.

You don't need a bunch of code as the other poster suggests...
 
In addition to my suggestion, if you want to FORCE the user to close a form
to return to the previous form, then use the
model setting in the forms "other" tab in the properties sheet.
 
Pietro ha scritto:
Thank you very much Sig. Alessandro
But what do you mean by "Call"
I need also an explaination for the function you wrote ,whre should put the
forms' name ?


The Function need as a parameter the form name's wich are not to be
close in the
cicle trought the Forms collection...!

So if you put the function on a Module on each form you open you can
call the function:

CloseAllForms Me.Name
or
Call CloseAllForms(Me.Name)

It's OK....?

@Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top