Unload form & background form

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

Guest

Hello -

I have an application with a background form and many other forms. The
background form has the 'X' part of the control box to close the form to exit
the application. I thought it would be nice to give a user the opportunity
to change their mind if they incorrectly clicked on the 'X,' and return them
to the form they were on. I have the following code, but I need the part
(the hard part) in capital letters below:

Private Sub Form_Unload()
If Me.Visible = True Then
'Exit application - give user one chance to change their mind
Dim frm As Form
NEED CODE FOR FORM USER IS CURRENTLY ON
If MsgBox("You are about to completely exit Call Tracking." &
Chr(13) & _
"Are you sure you want to do this?", vbYesNo + vbExclamation,
"Exiting Database") = vbNo Then
NEED CODE HERE TO KEEP BACKGROUND FORM VISIBLE
AND ALSO PARTICULAR FORM USER IS ON

Else
'Unload all forms and remove from memory
For Each frm In Forms
frm.Hide
Unload frm
Set frm = Nothing
Next

End
End If
Else
End If

Any help will be greatly appreciated!
 
NEED CODE FOR FORM USER IS CURRENTLY ON

set frm = screen.activeform

.... but if you are in the code behind your form, you can do
this:

set frm = Me

'~~~~~~~~
'moved a line of your code

For Each frm In Forms
frm.Hide
Unload frm
Next
'do this AFTER the loop
Set frm = Nothing

'~~~~~~~~

NEED CODE HERE TO KEEP BACKGROUND FORM VISIBLE
AND ALSO PARTICULAR FORM USER IS ON

perhaps you want to do this:

docmd.selectobject acform, backgroundformname
docmd.selectobject acform, particularformname

.... but why are you doing this?

anyway, you haven't declared the UNLOAD procedure right, it
has a CANCEL option...

Private Sub Form_Unload(Cancel As Integer)

if you decide NOT to unload it...
--> Cancel = true


Warm Regards,
Crystal
Microsoft Access MVP 2006

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
Back
Top