Hot Topic (More than 10 Replies) Stop adding new record (Read 1213 times)
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Stop adding new record
May 25th, 2007 at 5:28pm
Print Post Print Post  
Using version 1.14and keep having the problem where the user ends up adding anew record when pressing F10 or the Next arrow when they are on  the last record when Searching.  I thought that i saw a lot of different ways to stop this but not sure what is best for this version.  Is there a way to stop them from pressing F10 or if they press it can it be ignored and stay on the last record?  Some fields are filled in automatically when new record is opened.  Need to stop that to stop message that says exit without saving?  So what is the best way to stop this and make it work like it did in Q&A?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Stop adding new record
Reply #1 - May 25th, 2007 at 5:34pm
Print Post Print Post  
How are you stopping them in "add mode" (in Q&A or not)?
  

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: Stop adding new record
Reply #2 - May 25th, 2007 at 7:14pm
Print Post Print Post  
obfusc88,

I think this is what you are looking for:


Code
Select All
// Prevent Extended Mode
If @Update
	{
	// Be sure to always use the "Form" versions of these functions below when dealing with subforms,
	// otherwise Sesame can become confused and read the wrong one. This was happening while in a subform
	// and pressing Ctrl-F10. I could not navigate past the 2nd parent form because the subform of that 2nd
	// parent also had 2 records, which invoked this code.
	If @FormResultSetCurrentPosition(sThisFormName) = @FormResultSetTotal(sThisFormName)
		FormNotifyForm(sThisFormName, 2)
	Else
		FormNotifyForm(sThisFormName, -2)
	}
 



You would replace the variable named "sThisFormName" with the name of your main form, or set that variable to contain the name of your main form.

If you don't have any subforms, you could use the non "form..." versions like the following, but it won't hurt to use the example above.

Code
Select All
If @Update
	{
	If @ResultSetCurrentPosition() = @ResultSetTotal()
		{
		NotifyForm(2)
		}
	Else
		{
		NotifyForm(-2)
		}
	}
 

  


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


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: Stop adding new record
Reply #3 - May 29th, 2007 at 12:36am
Print Post Print Post  
For The Cow:  This is not a problem in Q&A becasue when in Search/Update, pressing F10 send message that No More Records Exist.

For Carl Underwood:  What you provided almost workdedd but i had to make some changes
You gave me this:
If @Update {
If @FormResultSetCurrentPosition(sThisFormName) = @FormResultSetTotal(sThisFormName)
           FormNotifyForm(sThisFormName, 2)
     Else
           FormNotifyForm(sThisFormName, -2)
     }
}

When I used that I kept getting a message the program did not compile when i tried to  open a form.  But when I did Test in Program Editor there was no errors.  I could not find FromNotifyForm in the manuals, but did find an example on page 193 of Programming Gguide.

The first thing that i found out was that i had to put quotes around the form name to meake it work.  And then I used NotifyForm like the sample showed. This is what I ended up with
If@Update {
If @FormResultSetCurrentPosition("sThisFormName") = @FormResultSetTotal("sThisFormName")
           NotifyForm(2)
     Else
           NotifyForm(-2)
     }

But now it is working but where do i find FormNotifyForm in the manuals?  Is this a special funciton that i need to make to use with this?  I am using subforms so i put the same programming in FormEntry sections on top form and the subform.  butt you said there would be troubles unless is used the programming that i cannot find.  I don't want to have problems but the message about not comiling is gone away now and pressing F10 does not go to a new record to be added.  That is good so far.  Also now when I press F10 in updateing mode, the record numbers on top of window flash count but come back to last record.  Is that flashing the trouble you warned about?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Stop adding new record
Reply #4 - May 29th, 2007 at 12:45am
Print Post Print Post  
obfusc88 wrote on May 29th, 2007 at 12:36am:
For Cow:  This is not a problem in Q&A becasue when in Search/Update, pressing F10 send message that No More Records Exist.


That wasn't my question. My question was (and is): what would you do in Q&A (or Sesame) in the exact same position in Add Mode? In Q&A, when you advance a new record to commit it you are on a new blank record - identical to the situation you are in in "extend mode".
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
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: Stop adding new record
Reply #5 - May 29th, 2007 at 1:33am
Print Post Print Post  
Quote:
But now it is working but where do i find FormNotifyForm in the manuals?  Is this a special funciton that i need to make to use with this?


@FormNotifyForm(formName as string) as int
FormNotifyForm(formName as string, flag as int)
@FormIsNotifyForm(formName as string, flag as int) as int

They are all added in Sesame Version 1.1.3 and you are not likely to find in version 1.1 programming manual.

https://www.lantica.com/Support/sesame_change_log.html

Please view the above Change Log.

Bharat Naik
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Stop adding new record
Reply #6 - May 29th, 2007 at 2:27am
Print Post Print Post  
obfusc88 wrote on May 29th, 2007 at 12:36am:
...where do i find FormNotifyForm in the manuals?

It's not in the manuals, since it was added to Sesame after the manuals were printed. You can find FormNotifyForm documented here: http://www.lantica.com/Support/sesame_change_log.html
It's under the section titled Version: 1.1.3

Quote:
The first thing that i found out was that i had to put quotes around the form name to meake it work.

You would need the quotes if you use the name of the form, but you would NOT use the quotes if you are using a variable to represent the form's name.

For example, if you want to use a variable, and the name of your main form is Checkbook, you could use the following code in the Global Code programming event. And then you would use the 1st code example I posted, exactly as it appears.
Code
Select All
stat sThisFormName as string = "Checkbook" 



Or you could modify the code by replacing sThisFormName, with "Checkbook" like the following code. (Of course, you would use the name of your main form in place of Checkbook.)
Code
Select All
If @Update
	{
	If @FormResultSetCurrentPosition("Checkbook") = @FormResultSetTotal("Checkbook")
		FormNotifyForm("Checkbook", 2)
	Else
		FormNotifyForm("Checkbook", -2)
	}
 



Quote:
I am using subforms so i put the same programming in FormEntry sections on top form and the subform.

I wouldn't recommend using the code in a subform.


Quote:
This is what I ended up with
If@Update {
If @FormResultSetCurrentPosition("sThisFormName") = @FormResultSetTotal("sThisFormName")
          NotifyForm(2)
    Else
          NotifyForm(-2)
    }

Unless your main form is really named sThisFormName, that's not correct.


Quote:
Also now when I press F10 in updateing mode, the record numbers on top of window flash count but come back to last record.  Is that flashing the trouble you warned about?

I do see the flashing sometimes, too. It's normal.
  


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: Stop adding new record
Reply #7 - May 29th, 2007 at 3:35am
Print Post Print Post  
This is the code that I have been using.   Similar to Carl's but does not use static variable.
Thic can be pasted into any form, and you only need to modify the value of vFormName

Code
Select All
var vFormName As String

//Set the name of the form on the next line
vFormName = "frmPhoneBook"

If @Update Then {
	If @FormResultSetCurrentPosition(vFormName) = @FormResultSetTotal(vFormName) Then {
		FormNotifyForm(vFormName, 2)
		} Else {
		FormNotifyForm(vFormName, -2)
		}
	}
 

Note that I have a naming convention that starts all form names with "frm".  But that's another issue.





  



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


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: Stop adding new record
Reply #8 - May 31st, 2007 at 3:17am
Print Post Print Post  
Thank you to so many helpers.  I never knew aobout the other documentation.  That is the best kep secret i never heard of,  it is now working for me just like you said it would.  But i still have a question,  why should this programming note be added to a subform.  I did add it but it does not seem to be working.  I can press the down arrow to make a new row in the subforms.  I am not worried that is not working becuae the up arrow make the new row go away.

And for The Cow, i don't have the problem in Q&A because when I am in Search and Update I don't wnat to add a record. and it does not change into add mode.  If i want to go to ADD i can press conrtol-F6 the same way you kept that in Sesame.  But it is a conscious effort to change from Update to ADD, not like Sesame does.  But now this does not happen because of the good help i got here.

  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Stop adding new record
Reply #9 - May 31st, 2007 at 3:49am
Print Post Print Post  
obfusc88 wrote on May 31st, 2007 at 3:17am:
why should this programming note be added to a subform.

Because, you may want to add a new subrecord to the subform while updating a main record.
  


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: Stop adding new record
Reply #10 - May 31st, 2007 at 11:36am
Print Post Print Post  
Quote:
And for The Cow, i don't have the problem in Q&A because when I am in Search and Update I don't wnat to add a record. and it does not change into add mode.  If i want to go to ADD i can press conrtol-F6 the same way you kept that in Sesame.  But it is a conscious effort to change from Update to ADD, not like Sesame does.  But now this does not happen because of the good help i got here.


The above isn't true. In Q&A (or Sesame) when the user adds a record, they are left on a NEW blank record, whether they intend to or not. This is true in Q&A in add mode. Q&A does not have extend mode because it is flat. Extend mode is necessary in all non-flat databases because it is the only way to add new records to an existing form. Of course, there are few database system that support the notion of "modes" whatsoever.

So if your user is in Q&A and they are in ADD mode, and they are moving back in forth in their records using F9 and F10, how are preventing your code that should apply to already committed records from running on the blank-ish one at the end of their set, and how are you preventing the code that should only run on a truly new record from running on the ones that they entered some time ago and are no revisiting to check for spelling errors - all in ADD mode?

My point being, it isn't question of what mode the program is in, that is a weak indicator of user intent. Instead concern yourself with the state of the records involved. Is this record new? Has it ever been committed? Is the user editing an old record? Are they editing a new but committed record?

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
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: Stop adding new record
Reply #11 - May 31st, 2007 at 7:37pm
Print Post Print Post  
Quote:
My point being, it isn't question of what mode the program is in, that is a weak indicator of user intent. Instead concern yourself with the state of the records involved. Is this record new? Has it ever been committed? Is the user editing an old record? Are they editing a new but committed record?


How is a "new but committed" record different from an "old" record?  I generally think of a record as "new" when it has not been committed, but once committed it's "old" (in terms of how a user would access it).
  

**
Captain Infinity
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: Stop adding new record
Reply #12 - May 31st, 2007 at 8:48pm
Print Post Print Post  
"New but commited" could be a record that has been saved by using Save Record on the menu tree but has not been moved off of yet. or it could be one that you just added and you have to go back to it cause you forgot to type in some piece of information.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Stop adding new record
Reply #13 - Jun 1st, 2007 at 12:59pm
Print Post Print Post  
Not to disagree too strongly with Ray (none of us can afford to do that), but that is not really what I intended. When I said "new but committed", I intended a record that the user had committed as part of their current session - a record created in add mode or "extend mode" that has been committed, but was created in this session by this user.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged