Hot Topic (More than 10 Replies) Checking for open tabs (Read 2725 times)
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Checking for open tabs
Mar 31st, 2005 at 2:37am
Print Post Print Post  
I'm trying find a way of checking to see if a form has any open tabs. I need to check for open tabs of another form in the same application (i.e. from within my custom menu form, I need to see if a tab for my Checkbook form is open.) I'm thinking, with all of the great tools Sesame has, there must be a way of checking for this condition.

I've tried @FormResultSetCurrentPosition("FormName") and @FormResultSetTotal("FormName"), which at first glance, appeared to be doing the trick by returning a "-1" (negative one) if all the tabs were closed, and a zero or higher if one tab was open. The problem is, they also return a "-1" if the Add and Search/Update tabs are both open.

Is there a function that I am overlooking that can tell me absolutely that all the tabs for a particular form are closed?

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Checking for open tabs
Reply #1 - Apr 1st, 2005 at 6:00pm
Print Post Print Post  
Anyone have comments or ideas on this topic?
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Checking for open tabs
Reply #2 - Apr 1st, 2005 at 6:35pm
Print Post Print Post  
I was thinking of trying to set a global variable for "current tab" when you entered/left a tab.  Then you could just check the global variable to see the value of the "current" tab.

My thought was that you could make an invisible fileld at the top left of each tab that would automatically be the first field entered, programming there could set the global variable.   You could use multiple global variables if you needed to monitor multiple forms and tabs.

But no way to clear it if you leave a tab and go to untabbed area. Sad 
Unless you only have tabs and no free space on the form that is not on a tab. ???

But hopefully this concept will trigger another better idea by someone......  Roll Eyes


  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Checking for open tabs
Reply #3 - Apr 1st, 2005 at 6:56pm
Print Post Print Post  
Carl,
The "form" commands are probably returning negative one when both modes are open becuase it cannot determine which of the two you are referring to. If you specify the form mode as part of the form name, the function can then determine which of the two open tabs you mean. You can do this be concatenating the mode onto the form name:

MyFormName:(add)
or
MyFormName:(update)
or
MyFormName:(search)
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Checking for open tabs
Reply #4 - Apr 1st, 2005 at 8:18pm
Print Post Print Post  
Thanks for responding guys!

Bob,
It appears you are referring to tabpages on a form. I am referring to the form itself being open. (I am running mass updates from a custom main menu that update another database in the same app.) But still, I think your idea may work for my situation because since I am referring to a form tab (vs. tabpage), I can set a global value upon form entry and again at form exit. This may do the trick. Smiley


Mark,
I am not quite sure exactly what you mean. I understand the concept - I just don't know where/how I can add the form's mode to the name of the form. Is there a function to dynamically change the name that appears on the form tab? Or are you suggesting that I make copies of my form, and use one for adding and another for updating?
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Checking for open tabs
Reply #5 - Apr 1st, 2005 at 8:37pm
Print Post Print Post  
Quote:
Mark,
I am not quite sure exactly what you mean. I understand the concept - I just don't know where/how I can add the form's mode to the name of the form. Is there a function to dynamically change the name that appears on the form tab? Or are you suggesting that I make copies of my form, and use one for adding and another for updating?

No, change the name specified in the function call itself. For example, lets say you have a form named "MyForm". You would call the function with:
Code
Select All
var total as int
total = @FormResultSetTotal("MyForm:(add)")
 


to check if that form is open in add mode.
To check if it is open in search mode use:
Code
Select All
total = @FormResultSetTotal("MyForm:(search)")
 


The "form" functions know to look in the form name string passed to them for a colon (":") followed by an open parenthesis and a mode string - to indicate which mode for that form you are interested in.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Checking for open tabs
Reply #6 - Apr 1st, 2005 at 9:05pm
Print Post Print Post  
Mark,

This is the EXACT answer I was hoping for!  8)

I had no idea that we could do that. I don't see that mentioned in the programming guide. Is it documented somewhere?
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Checking for open tabs
Reply #7 - Apr 1st, 2005 at 9:16pm
Print Post Print Post  
Quote:
Mark,

This is the EXACT answer I was hoping for!  8)

Be forewarned, while that is how you specify the mode, I have never tested it for the purpose you are proposing.
Quote:
I had no idea that we could do that. I don't see that mentioned in the programming guide. Is it documented somewhere?

Sorry - I don't know if (or where) it got documented. I am not on the documentation team. Erika is checking into it now.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Checking for open tabs
Reply #8 - Apr 1st, 2005 at 9:24pm
Print Post Print Post  
Carl,

I'm looking for where this got documented.  Meanwhile, here's the note from the 1.0.3 Change Log:

# Expand Form commands like @FormFieldValue to accept (but not require) the full path to the Form and the mode, to allow for situations where the same Form is open in multiple tabs. You can now specify which Form and mode to affect. Examples:
@FormFieldValue("Countries!Cites:(add)", "Population", 1)
@FormFieldValue("Countries!Cites:(update)", "Population", 1)
@FormFieldValue("Countries!Cites:(search)", "Population", 1)

# Improve Form commands to better determine which instance of a Form to affect. If the Form Path and mode are not supplied, Sesame will look for a matching Form name in the following order:
Current Form
Child of current form recursively
Parent of current form recursively
If not found, fails setting the @Error flag.
Example:
@FormFieldValue("Cites", "Population", 1)
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Checking for open tabs
Reply #9 - Apr 1st, 2005 at 9:47pm
Print Post Print Post  
You know... I didn't even think to look in the change logs, I just assumed that since the programming guide was only 2 weeks old, that it would have all the information available.  Wink
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Checking for open tabs
Reply #10 - Apr 2nd, 2005 at 2:03am
Print Post Print Post  
I have impemented Mark's suggestion, and it works perfectly!!! Grin Grin Grin

Like I said, it's EXACTLY what I was hoping for!
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Checking for open tabs
Reply #11 - Apr 2nd, 2005 at 7:46pm
Print Post Print Post  
Carl, I am wondering, after finding out what forms are open, what code have you used from the menu form to close those open forms?
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Checking for open tabs
Reply #12 - Apr 2nd, 2005 at 10:38pm
Print Post Print Post  
Bharat,

I'm not closing the open forms via programming. I am using the info in an If..Then statement that either performs some actions on the database (via mass updates), or pops up a MsgBox that diplays a message telling what needs to be done before this task can run (i.e. close the open tabs of the target database).

Besides, I don't believe you can close an open form with programming. (I've tried that before and nothing happens.) I think it's by design.

And actually, I would not want to close any open tabs automatically. I know I could cause the record to be saved first, but the data on the form still may not be completed yet. If I have to close it manually, then I can be sure it is saved in a completed state.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Checking for open tabs
Reply #13 - Apr 2nd, 2005 at 10:44pm
Print Post Print Post  
Bharat,

In case you're interested, here's the actual code in use:

Code
Select All
var success as Int

if (@FormResultSetTotal("Checkbook:(Add)") = -1) and (@FormResultSetTotal("Checkbook:(Search)") = -1) and (@FormResultSetTotal("Checkbook:(Update)") = -1)
	{
	if @xlu(@fn, 1, "Checkbook!Print", "Print") = 1
		{
		GlobalValue("PrintChecks",1)
		success = @SelectTreeItem(@Application + "!Forms!Search/Update!Checkbook!Checkbook")
		}
	else
		@MsgBox("", "There are no checks to print.", "")
	}
else
	@MsgBox("All the Checkbook tabs must be closed to print checks.", "", "Close the tabs, and select PRINT CHECKS again.")
 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Checking for open tabs
Reply #14 - Apr 3rd, 2005 at 4:02am
Print Post Print Post  
Carl, got it. Thank you.
  
Back to top
 
IP Logged