Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) Add Data Mode able to add blank records with res. (Read 2715 times)
Frederick_JH
Junior Member
**
Offline


Open Sesame . . . the
magic portal awaits!

Posts: 52
Joined: Jan 26th, 2004
Add Data Mode able to add blank records with res.
Mar 1st, 2006 at 10:37pm
Print Post Print Post  
I  have added programing to my form to guide the user to enter the correct information properly and added restriction to the form to ensure this as well. However all a user has to do to get around this is enter the add data mode and press F10 each time they do this a blank record is added. I am having a hard time trying to figure out what in my code could be causing this here in the code. I do apologize as it is long.
Code
Select All
var vLength as int = 0 // Variable for length error test
var vMessage as string = "" // Variable used to generate custom error message
if @isblank(ThisElement) then
{

	// Check to make sure that the short form is not blank.
	if @isblank(ThisElement) then vEntryErrorCount = vEntryErrorCount + 1 //Error variable counts a few times before getting in the users face
	if @isblank(ThisElement) and vEntryErrorCount > 3 then @MsgBox("You seem to be having some trouble here.","You must enter a Short Form.","Without it this record is useless!")
	if @isblank(ThisElement) then
	{
		@msg("WARNING! ShortForm IS A REQIRED FIELD")
		@Play("Beep")
		throwfocus(ThisElement)
	}
}
else
{
// Check to make sure the Short Form is 2 to 5 Characters long
	vWork = 0;
	vWork = @tn(@len(ThisElement)); //Put the length of the short form in the variable.
	if vWork < "2" or vWork > "6"  then vLength = 1 else vLength = 0;
	if vLength = 1 then vEntryErrorCountA = (vEntryErrorCountA + 1) //Error variable counts a few times before getting in the users face
	if vLength = 1 and (vEntryErrorCountA > 3) then @MsgBox("You seem to be having some trouble here.","A Short Form must be 2 to 6 characters long.","Please try again!")
	if vLength = 1 then
	{
		@msg ("WARNING! THIS FIELD MUST BE 2 TO 6 CHARACTERS")
		@Play("Beep")
		throwfocus(ThisElement)
	}
}

// Check to see if the Short Form already exists in the database if this is a new record that has not been save yet
ThisElement = ToUpper(ThisElement) // Converts this field to upper case
if (ShortForm = @xlu(@fn,ShortForm,"ProgramInformation!ShortForm","ShortForm")) and (not @error) and @IsNew then
{
	vEntryErrorCountB = vEntryErrorCountB + 1 //Error variable counts a few times before getting in the users face
	vMessage = "The Short Form "
	vMessage += (@xlu(@fn,ShortForm,"ProgramInformation!ShortForm","ShortForm"))
	vMessage += " already exists for "
	vMessage += @xlu(@fn,ShortForm,"ProgramInformation!ShortForm","Programname")
}
if (ShortForm = @xlu(@fn,ShortForm,"ProgramInformation!ShortForm","ShortForm")) and (not @error) and @IsNew and (vEntryErrorCountB > 3) then
{
	@msgbox(vMessage,"Please enter a unique Short Form.","It must be be 2 to 6 characters long")
}
if (ShortForm = @xlu(@fn,ShortForm,"ProgramInformation!ShortForm","ShortForm")) and (not @error) and @IsNew then
{

	@msg(ToUpper(vMessage))
	@Play("Beep")
	throwfocus(ThisElement)
}

// Check to see if the Short Form is the same as a base filename already in the database if this is a new record that has not been save yet
ThisElement = ToUpper(ThisElement) // Converts this field to upper case
if (ShortForm = @xlu(@fn,ShortForm,"ProgramInformation!BaseFilename","BaseFilename")) and (not @error) and @IsNew then
{
	vEntryErrorCountC = vEntryErrorCountC + 1 //Error variable counts a few times before getting in the users face
	vMessage = "The Short Form "
	vMessage += (@xlu(@fn,ShortForm,"ProgramInformation!BaseFilename","ShortForm"))
	vMessage += " already exists as a Base Filename for "
	vMessage += @xlu(@fn,ShortForm,"ProgramInformation!BaseFilename","Programname")
}
if (ShortForm = @xlu(@fn,ShortForm,"ProgramInformation!BaseFilename","BaseFilename")) and (not @error) and @IsNew and (vEntryErrorCountC > 3) then
{
	@msgbox(vMessage ,"It must not be a Base Filename for another program.","It must be be 2 to 6 characters long")
}
if (ShortForm = @xlu(@fn,ShortForm,"ProgramInformation!BaseFilename","BaseFilename")) and (not @error) and @IsNew then
{

	@msg(ToUpper(vMessage))
	@Play("Beep")
	throwfocus(ThisElement)
}

//If all is well and we are moving on set the error counter variables to 0
if (not @isblank(ThisElement)) and (not vLength = 1) and (not (ShortForm = @xlu(@fn,ShortForm,"ProgramInformation!ShortForm","ShortForm"))) and (not (ShortForm = @xlu(@fn,ShortForm,"ProgramInformation!BaseFilename","BaseFilename"))) and (not @error) and @isnew then
{
	vEntryErrorCount = 0
	vEntryErrorCountA = 0
	vEntryErrorCountB = 0
	vEntryErrorCountC = 0
	Cnext
}
 



A note to Ray this is in the application I sent you earlier today. Just go into the Program Information form in add data mode and hit F10 to replicate.

Anyone got any ideas?

This does not seem to be normal behaviour. I went into the Customers database and added restrictions to a few fields and threw in the first section about the record not being blank but it refused to add a blank record.
  

Frederick Henderson*Radio HRGS*Roatan*Bay Islands*Honduras
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: Add Data Mode able to add blank records with r
Reply #1 - Mar 1st, 2006 at 10:47pm
Print Post Print Post  
Hello Frederick,

The records are not completely blank. Look at the very bottom. You have three elements filled in.

EditedDate
EditedTime
Editor

They are being filled in by the On Form Exit events of those three elements.

-Ray
  

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


Open Sesame . . . the
magic portal awaits!

Posts: 52
Joined: Jan 26th, 2004
Re: Add Data Mode able to add blank records with r
Reply #2 - Mar 1st, 2006 at 11:04pm
Print Post Print Post  
Thank you Ray for pointing that out.

So now the question is why does Sesame save the record as there are Entry Required restrictions on several fields have not been met?
  

Frederick Henderson*Radio HRGS*Roatan*Bay Islands*Honduras
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Add Data Mode able to add blank records with r
Reply #3 - Mar 2nd, 2006 at 1:55am
Print Post Print Post  
Table view subform?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Frederick_JH
Junior Member
**
Offline


Open Sesame . . . the
magic portal awaits!

Posts: 52
Joined: Jan 26th, 2004
Re: Add Data Mode able to add blank records with r
Reply #4 - Mar 2nd, 2006 at 4:15am
Print Post Print Post  
Quote:
Posted by: The Cow      Posted on: Today at 19:55:34      
Table view subform?


There is no sub-form nor is this in Table view.

It is very strange that it would do this. Add data mode in the first element press F10 it runs through the programing then adds a partially filled out record to the database. 5 elements have the Required Entry restriction and not a one of them on these records has anything in them.
  

Frederick Henderson*Radio HRGS*Roatan*Bay Islands*Honduras
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Add Data Mode able to add blank records with r
Reply #5 - Mar 2nd, 2006 at 2:44pm
Print Post Print Post  
Sesame does not check restrictions on records that have not been altered by the user and are new. We assume that if the only changes on the record are produced by programming, that those changes are intentional on the part of the programmer and will automatically meet the restrictions, or it is okay if they don't.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Frederick_JH
Junior Member
**
Offline


Open Sesame . . . the
magic portal awaits!

Posts: 52
Joined: Jan 26th, 2004
Re: Add Data Mode able to add blank records with r
Reply #6 - Mar 2nd, 2006 at 2:56pm
Print Post Print Post  
What you are saying is that since my exit form programing is non-conditional and fills in three fields and the user has not altered the record in anyway Sesame saves the record without checking restrictions.

So, what I need to do is make my exit form programing conditional so that as long as the form is blank it does not run. That way the user has to make the first entry and then Sesame will check the restrictions.

Thanks for letting me know this. I was unaware of this fact. Do you know if it is in the manuals. If it is it should be in bold print with an exclamation point sign in the margin like the icon for this message.

Thanks again for your help!   8)
  

Frederick Henderson*Radio HRGS*Roatan*Bay Islands*Honduras
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Add Data Mode able to add blank records with r
Reply #7 - Mar 2nd, 2006 at 3:18pm
Print Post Print Post  
Frederick,

You may want to look at the June 2004 issue of Inside Sesame. I wrote an article in that issue showing safe and effective data validation methods that protect the data and inform the user without creating traps.

In particular, look into the NotifyForm command.

Sesame can do something very important that Q&A could not. Sesame allows the programmer to conditionally prevent the record from saving. This gives you options that were not previously available to you. You might want to check them out.

Restrictions are supported for Q&A compatibility, but Sesame also provides cleaner, more flexible, more reliable methods through SBasic. Since writing code is not a problem for you, consider switching over.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Frederick_JH
Junior Member
**
Offline


Open Sesame . . . the
magic portal awaits!

Posts: 52
Joined: Jan 26th, 2004
Re: Add Data Mode able to add blank records with r
Reply #8 - Mar 2nd, 2006 at 8:37pm
Print Post Print Post  
Thanks Erika for the article. It looks like I will be changing the way I validate data and I promise not to unduly put the user in a trap as I do not want them cursing my name. After reading all this and thinking about it are there any other things from Q&A that are better not done in Sesame. So far this is my  list:

goto (use throwfocus() and conditional statements insead)
restrictions (use programing to  conditionally prevent the record from saving)

Anyone have one to add?
  

Frederick Henderson*Radio HRGS*Roatan*Bay Islands*Honduras
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: Add Data Mode able to add blank records with r
Reply #9 - Mar 2nd, 2006 at 8:44pm
Print Post Print Post  
One more thing to add to your list is 'Don't use Stop'. You can avoid it in almost every case. A conditional can be used instead.

So instead of something like

Code
Select All
If Something = "Wrong" Then
{
Stop
}
Additional Code goes here 



You would have

Code
Select All
If Something <> "Wrong" Then
{
Additional Code goes here
} 



It is easier to understand, easier to debug, easier to update, and is better programming.

-Ray
  

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


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Add Data Mode able to add blank records with r
Reply #10 - Mar 2nd, 2006 at 8:48pm
Print Post Print Post  
Quote:
Anyone have one to add?


Use @IsBlank and Clear instead of ""

Use @IsNew instead of @Add/@Update

Use Functions and Subroutines instead of GOSUB, RETURN and STOP

Use variables instead of Programming Only/Shadow/Print Only elements/fields

Use On Element Change instead of On Element Exit

(I could do this all day, but I'll let somebody else take a turn. Smiley )
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
digimom1962
Junior Member
**
Offline


Natalie Gann

Posts: 92
Location: here
Joined: Nov 26th, 2004
Re: Add Data Mode able to add blank records with r
Reply #11 - Mar 31st, 2006 at 4:03pm
Print Post Print Post  
Quote:
Sesame does not check restrictions on records that have not been altered by the user and are new. We assume that if the only changes on the record are produced by programming, that those changes are intentional on the part of the programmer and will automatically meet the restrictions, or it is okay if they don't.
Shocked
Is there a way to make that assumption an optional thing?

I have been having the same problem and am glad to see it wasn't just me. The trouble is, if I have it set up thru programming so they cannot save a record without the ticket# & the user added the page accidentally (very possible here) and doesn't WANT to save it they have to press escape & start all over or save a blank ticket that was un-needed. (all it takes is 1 click in the sub-form and it's all over) We are having enough trouble getting people to agree to Sesame over Q&A without little pesty things like this popping up to give them a reason NOT to switch.
I think I am just going to set up a message box warning but I don't think it would really help if they pressed F10 multiple times fast.Tongue Thanx

PS: I am hoping I have overlooked something again. I don't really mind being called out as ignorant if it saves time and works better Roll Eyes
  

So much time and so little to do . . . strike that, reverse it.
Back to top
YIM YIM  
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Add Data Mode able to add blank records with r
Reply #12 - Mar 31st, 2006 at 4:19pm
Print Post Print Post  
Quote:
Shocked
Is there a way to make that assumption an optional thing?


Yes. Program it differently.  Smiley

Seriously, I'm not trying to be glib here. You have all the options in the world because the situation is created by specific instructions in your programming. If you don't like the behavior, give different instructions.

For example, if setting values On Form Entry is causing behavior you don't like, don't set the values On Form Entry. Set them on a different event, such as when the user enters a value themselves elsewhere on the Form. That way, the condition of a new record which is not blank, but which has no values that were altered by the user never occurs.

You can also use On Form Exit programming to prevent your record from being saved, rather than depending on Restrictions, which behave in a way that allows you, as the programmer, to do things that you might not allow the user to do on their own.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
digimom1962
Junior Member
**
Offline


Natalie Gann

Posts: 92
Location: here
Joined: Nov 26th, 2004
Re: Add Data Mode able to add blank records with r
Reply #13 - Mar 31st, 2006 at 5:15pm
Print Post Print Post  
Ugly Programming alert!! Brace yourself. (on form exit on a sub form)

if @formisstandalone() = 0 then

{

    if (@isblank(ticket_number))
         {
//            notifyform(1)
//            writeln("Cannot save without ticket number. Press escape to exit. ")
           writeln("Cannot save without ticket number.")
         }

  else

         {
           if (Not @isblank(ticket_number))
             {
                 notifyform(4)
           
             }

         }

}

If @formisstandalone() = 1 then

{

  if (Not @isblank(ticket_number))

    {
     notifyform(4)
    }
  if (@isblank(ticket_number))
    {

     notifyform(0)

    }
}
Originally I had set the restrictions to keep from advancing if there was no ticket #. When that didn't work(and now I know why) I set this programing up with help from the good folks on the board. It worked so well the user was stuck in a morass of error messages and no simple way out. I took out the part that prevented saving and just put in a message warning but it is still nerve-racking to get past the error message. you have to ignore the error message and click on the arrow to go back then you STILL get the error message again. I really like the optional restrictions for this issue but it is just not available in this situation.  ???  Maybe I have some redundency somewhere causing issues. (maybe I talk too much Roll Eyes)

Thanx a bunch
  

So much time and so little to do . . . strike that, reverse it.
Back to top
YIM YIM  
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Add Data Mode able to add blank records with r
Reply #14 - Mar 31st, 2006 at 9:42pm
Print Post Print Post  
Check @Modified as well as checking @IsBlank(). This way the user does not get an error message if they have not changed anything.

You probably want to be setting NotifyForm(4) on Form Entry rather than Form Exit. The reason for this is say you have two records, one has a ticket_number and the other one does not. If you leave the record that does not have a ticket_number, and go to the record that has a valid ticket_number, the On Form Exit event runs. Since on the record that you are leaving ticket_number is blank, NotifyForm(0) gets called and allows the user to delete records. This means they can delete the record that has ticket_number filled in.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print