I know that this works for the complete app to stop a duplicate app from running
If App.PrevInstance = True Then
End
End If
How can I modify this code to not allow a form from being opened more than once at the same time.
Thanks for your help
Printable View
I know that this works for the complete app to stop a duplicate app from running
If App.PrevInstance = True Then
End
End If
How can I modify this code to not allow a form from being opened more than once at the same time.
Thanks for your help
Form does not open twice unless you wish to open.
Simply saying form1.show twice will not open the form1 twice.
well it is a bit more complicated than that in my app.
I have a full screen mainform from that I have solved the user from minimizing it and opening another by the code shown in the original post.
However the main form allows the user to open a claim "record" and if he trys he can open a second claim "record" which actually gets really messed up and intermingled with the first. So I'm trying to prevent the user from opening a second record while the first is still open by not allowing the form containing the record to be opened a second time.
Hope that makes some sense of my mess.
Thanks for the help
I dont understand exactly but you would loop thru the forms and see if the one yer talking about is open and if it is then dont open another one. heres a function to use.. Put the function in a Bas or in your form
VB Code:
Function IsFrmOpen(FrmName As String) As Boolean Dim ofrm As Form For Each ofrm In Forms If ofrm.Name = FrmName Then IsFrmOpen = True Exit For End If Next ofrm End Function
then to use it just go like this..
VB Code:
If IsFrmOpen("Form2") Then MsgBox "It's open"
Thanks for the help Arc
I will give that a try.
Thanks again for the help
If you really do not want user to open the 2nd record while the 1st is open, you should be opening the form in modal mode.
form1.show vbmodal is the syntax. That will prevent the re-opening of form cause it will force the user to close the 1st one before opening 2nd.