Im using app.previnstance to end the program if a copy is already running.
In form_load:
But Im also using form_queryunload in the form, to detect if someone clicks the X (close) on the form.
Im using form_queryunload to detect if any settings on the form have changed and ask user if (s)he wants to save settings.
But when I run the program, and try to run it again, it pops up asking if I want to save changes. Also, even if I click No, the task manager still shows two instances of the app running.
here is the app.previnstance in my form_load:
Here is my form_queryunload code:
What is the proper way to do this?
Thanks.
In form_load:
Code:
If App.PrevInstance Then Unload Me: Exit Sub
But Im also using form_queryunload in the form, to detect if someone clicks the X (close) on the form.
Im using form_queryunload to detect if any settings on the form have changed and ask user if (s)he wants to save settings.
But when I run the program, and try to run it again, it pops up asking if I want to save changes. Also, even if I click No, the task manager still shows two instances of the app running.
here is the app.previnstance in my form_load:
Code:
Private Sub Form_Load()
If App.PrevInstance Then Unload Me: Exit Sub
Here is my form_queryunload code:
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'this sub senses the closing of a form.
'next, run sub that checks for changes.
check_for_changes
'Next, close all open forms in project
Dim f As Form
For Each f In Forms
If f.Name <> Me.Name Then Unload f
Next
'Finally close the main, or last form that this routine is in
Unload Me
End Sub
What is the proper way to do this?
Thanks.