Know when a form is closed

  • Thread starter Thread starter Dean Simpson
  • Start date Start date
D

Dean Simpson

Does any one know how to find out if a form has been closed

What I am trying to do is to open a form from a list box(Which passes data
to the newly opened form) and when the form is closed, the list box on the
original form, is refreshed to show changes made. Unfortunatley, the newly
opened form is used elsewhere and I cannot put the code in
'forms!myforms1.lstbox requery'when closing as when used by another
procedure, it throws up the error message 'unable to find form myform'

I know that when you open a form you can used the acdiag in the parameters
and put the desired code underneath but I am unable to do this for this
cirumstance.

I have run out of ideas can anyone help
Thanks in advanced
 
In Access 2000 and later, you can use:
If CurrentProject.AllForms("MyForm").IsLoaded Then

In older versions, copy the IsLoaded() function from the Utility module of
the Northwind sample database.
 
Thanks for quick response amd it works fine, except for what I am doing it
isn't working.

Once a button is pressed to create a new record, a new form opens. Now I
can change focus to the previous form where I have just pressed the button.
The problem I have is getting a listbox to update once the new record has
been created.

I tried using your solution by inserting the code in the 'GotFocus' in the
original form, but when I click my mouse buton on the form, no message box
appears. ( if isload(form) then msgbox "StillOpen"). I've tried OnFocus,
OnClick.

Have you any idea's
 
Use the AfterUpdate event procedure of the form where the new record is
entered to Requery the list box on the previous form:

Private Sub Form_AfterUpdate()
If CurrentProject.AllForms("MyForm").IsLoaded Then
Forms("MyForm")![MyListbox].Requery
End If
End Sub

For the approach you were taking, you were probably searching for the form's
Activate event (rather than GotFocus).
 
Thanks so much.

As soon as I read it I knew it would work and it did

Thanks again

Allen Browne said:
Use the AfterUpdate event procedure of the form where the new record is
entered to Requery the list box on the previous form:

Private Sub Form_AfterUpdate()
If CurrentProject.AllForms("MyForm").IsLoaded Then
Forms("MyForm")![MyListbox].Requery
End If
End Sub

For the approach you were taking, you were probably searching for the form's
Activate event (rather than GotFocus).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dean Simpson said:
Thanks for quick response amd it works fine, except for what I am doing it
isn't working.

Once a button is pressed to create a new record, a new form opens. Now I
can change focus to the previous form where I have just pressed the
button.
The problem I have is getting a listbox to update once the new record has
been created.

I tried using your solution by inserting the code in the 'GotFocus' in the
original form, but when I click my mouse buton on the form, no message box
appears. ( if isload(form) then msgbox "StillOpen"). I've tried OnFocus,
OnClick.

Have you any idea's

on
the
 
Back
Top