Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to check if a form is already open, if not then open it. 1

Status
Not open for further replies.

Triedit

Technical User
Mar 9, 2001
28
0
0
GB
I'm trying to devise a simple messaging system, and I want to open the form when users open the main menu on our db.

I can get the message form to open with the main menu, but if users close the main menu and then open it again the message form opens again too, so users will then have the message form open more than once.

I need some help with code that will check to see if the message form is already open, if it is, I don't want it to open a second copy.

Does that make sense? Hope someone can help....Lance, Perrin, anybody, please!?

Thanks

Annie
 
Annie,

I find the easiest way to do this is to try and attatch to the forms title, if the attach fails open the form. If you have not yet assigned a title to the form do so by right mouse clicking on the title bar and select "Window Style" and give the form a title. Then from your menu when you open the form you can add something like:

var
f form
endvar

if f.attach("Form Title") then
f.bringToTop() ; Bring the form to the top
else
f.open("MessageForm") ; Open the form if it's not already open
endif

I like to add f.bringToTop() to bring the open form to the top of the workspace incase it's hiding.

Let me know if you have any problems
Perrin
 
Perrin, no probs whatsoever, thanks again

Annie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top