Normal Topic @Save and @selectTreeItem( )  not commiting & (Read 1287 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
@Save and @selectTreeItem( )  not commiting &
Apr 25th, 2007 at 7:49am
Print Post Print Post  
I have a command button with following code at the end. The command button and @selectTreeItem( ) execute successfully still when I press Esc or F7 to go for Search mode, it tells me that "Record is changed and not committed, Do you want exit without saving?"

I thought only @Save should do the job but when it did not I put additional @SelectTreeItem( ) and still it  is not committing the record to database. One has to hit <F10> to commit the record. Programming manual clearly states that @Save does the same job as F10 keys.  Huh    What am I doing wrong?

Code
Select All
var nn as Int

@Save
nn = @SelectTreeItem ("Search Update Menu!Navigation!Advance Record (F10)")

/*
If nn = 1 then

	{
		Writeln ("Mission Successful!", "", "")
	}
	Else
	{
		WriteLn ("Mission Failed!", "", "")
	}
*/

 

  
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: @Save and @selectTreeItem( )  not commiti
Reply #1 - Apr 25th, 2007 at 12:22pm
Print Post Print Post  
I have the following code On Form Enter event.
Code
Select All
//Prevent Extend mode from update mode

If @Update Then
{
If @ResultSetCurrentPosition() = @ResultSetTotal() Then
{
NotifyForm(2)
}
Else
{
NotifyForm(-2)
}
}

 



So, it should not allow the form to advance to next record to go in the extended mode. However, @Save command should work. If I use "Save Record" command by clicking into the command tree it works and no flag will show up when I go to Search mode using F7 key. The same thing will fail if I use Save Record command with @SelectTreeItem( ).  I also noticed that if I use @SelectTreeItem( ) for Save Record, that item in the Navigation group turns red and remains red until I click it again. May be @SelectTreeItem ( ) command triggers it but cannot complete the command.

The questions are why @save in programming does not act the same as hard pressed Save Record in command tree? Why @SelectCommandTree ( ) command does not work the same as actually selecting item in the command tree with mouse? Why F10 pressed key behave differently than when activated through @SelectTreeItem ( ).
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: @Save and @selectTreeItem( )  not commiti
Reply #2 - Apr 25th, 2007 at 1:30pm
Print Post Print Post  
Hello Bharat,

Do you have any programming in the on Form Entry event that may be changing the record?

Quote:
The questions are why @save in programming does not act the same as hard pressed Save Record in command tree?

@Save will save the record and advance it while that particular menu item only Saves the record. @Save in Sesame does the same thing that it did in Q&A.

Quote:
Why @SelectCommandTree ( ) command does not work the same as actually selecting item in the command tree with mouse?

The only commands that @SelectTreeItem() can not run off the menu tree are any command that will close the form so "Exit Add Data", "Exit Search Menu" and "Exit Search/Update" will not work if you try to select them with @SelectTreeItem(). All other commands as long as the path is right will work like they had been selected off the menu tree.

Quote:
Why F10 pressed key behave differently than when activated through @SelectTreeItem ( ).

I am not seeing @SelectTreeItem('path to F10') behaving any differently than F10, They both commit any changes that I have made to the record and when I press F7 or Esc the form closes without giving me any error messages. So it appears to me that something is changing the record after it is commited.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: @Save and @selectTreeItem( )  not commiti
Reply #3 - Apr 25th, 2007 at 5:14pm
Print Post Print Post  
I'm having the same problem (or similar, if I'm reading Bharat right).  Here is a piece of my code for a "Save and Continue" button.  It's meant to Save the changes to the record but then block extended mode.
Code
Select All
If @Mode() = 1  // Saves and advances in Update mode, Prevents entering Extended Mode from Search-Update
THEN
	{
	IF @ResultSetCurrentPosition() = @ResultSetTotal()
	THEN
		{
		NotifyForm(2)
		}
	ELSE
		{
		Clear(Checkcode)
		NotifyForm(0)
		vNextRecord = @selecttreeitem("Search Update Menu!Navigation!Advance Record (F10)")
		}
	}


ELSE  If @Mode() = 0  // Saves and advances in Add mode
	{
	Clear(Checkcode)
	NotifyForm(0)
	vNextRecord = @selecttreeitem("Add data menu!Navigation!Advance Record (F10)")
	} 



This works fine for Add Mode, and for all records in Update mode except the last.  When it comes to the last record in the result set, it doesn't advance into Extended (yay) but changes are not saved either.  Do I need to shuffle my "vNextRecord =" statement to some other position?
  

**
Captain Infinity
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: @Save and @selectTreeItem( )  not commiti
Reply #4 - Apr 25th, 2007 at 6:07pm
Print Post Print Post  
Yes Infinity, I have the same problem. F10 will save the record but @SelectTreeItem ( ) would not when it comes to moving to extended mode. It would not move to extended mode because of NotifyForm () but would not save the file either. I am thinking about changing the design so, instead of using button the user has to press F10 key in order to avoid the record changes not saved.  Ray, if you want to see what I am talking about, I can send you the file. Since I am thinking about removing that button and force user to use F10 instead, so it would not matter much.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: @Save and @selectTreeItem( )  not commiti
Reply #5 - Apr 25th, 2007 at 6:07pm
Print Post Print Post  
Hello Scott,

Your problem is in your code. If you are on your last record you are only setting NotifyForm(2) and not actually saving the record.

Try something like this
Code
Select All
If @Mode() = 1  // Saves and advances in Update mode, Prevents entering Extended Mode from Search-Update
THEN
	{
	IF @ResultSetCurrentPosition() = @ResultSetTotal()
	THEN
		{
		Clear(Checkcode)
		NotifyForm(2)
		vNextRecord = @selecttreeitem("Search Update Menu!Navigation!Advance Record (F10)")
		}
	ELSE
		{
		Clear(Checkcode)
		NotifyForm(0)
		vNextRecord = @selecttreeitem("Search Update Menu!Navigation!Advance Record (F10)")
		}
	}


ELSE  If @Mode() = 0  // Saves and advances in Add mode
	{
	Clear(Checkcode)
	NotifyForm(0)
	vNextRecord = @selecttreeitem("Add data menu!Navigation!Advance Record (F10)")
	}  



Also your code will only prevent extend mode if the user used this button to go to the last record. It will not stop extend mode if the user uses the F10 key, the navigation buttons at the top, or use the menu tree.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: @Save and @selectTreeItem( )  not commiti
Reply #6 - Apr 25th, 2007 at 6:09pm
Print Post Print Post  
Bharat_Naik wrote on Apr 25th, 2007 at 6:07pm:
Yes Infinity, I have the same problem. F10 will save the record but @SelectTreeItem ( ) would not when it comes to moving to extended mode. It would not move to extended mode because of NotifyForm () but would not save the file either. I am thinking about changing the design so, instead of using button the user has to press F10 key in order to avoid the record changes not saved.  Ray, if you want to see what I am talking about, I can send you the file. Since I am thinking about removing that button and force user to use F10 instead, so it would not matter much.



Hello Bharat,

Yes if you can send me your file and I'll have a look at it here and see what is happening.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
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: @Save and @selectTreeItem( )  not commiti
Reply #7 - Apr 25th, 2007 at 6:30pm
Print Post Print Post  
Thanks Ray, I will do that. I know Infinity is busy giving finishing touch to his application but if the time permits, can you verify with your file whether @selectTreeItem ( ) with "Save Record" and @Save command in programming does or does not save the record when it comes to last record before moving to extended mode in Update mode.

Bharat
  
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: @Save and @selectTreeItem( )  not commiti
Reply #8 - Apr 26th, 2007 at 6:07am
Print Post Print Post  
I took customer.db and placed two command buttons, one to Save Using F10 and other to "Save Record" both of them call @SelectTreeItem( ). Also placed the programming in Form Enter event to prevent it from going into "Extend Mode".  Searched and selected only one record. and used command buttons to study the problem I am having.  Everything worked perfectly like it is supposed to work. I have come to conclusion that what problem I am having, is related to my application and programing in it.

Since I plan to change the design to overcome the problem I am having, I do not think I should waste your time looking into the application and find the culprit code. So, I would not be sending the application but I thank you very much for going extra mile to show willingness to help me.

Bharat
  
Back to top
 
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: @Save and @selectTreeItem( )  not commiti
Reply #9 - Apr 26th, 2007 at 1:42pm
Print Post Print Post  
Ray wrote:
Quote:
Your problem is in your code. If you are on your last record you are only setting NotifyForm(2) and not actually saving the record.

Try something like this

(Code snipped)

D'oh!  Of course, it was staring me right in the face.  Thanks Ray.
  

**
Captain Infinity
Back to top
IP Logged