Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) On Form Change Programming (Read 4328 times)
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
On Form Change Programming
Mar 4th, 2005 at 6:37pm
Print Post Print Post  
Hi -

I am having a difficult time using programming to be executed "on form change."

My need is simple.  If indeed I make a change to any of the data on a form I need my Last Udate Layout Element to be updated to reflect the current date.

I thought the programming would be simple and used:

Code
Select All
Last Updated = @date 



The problem is that if I am simply searching through a stack of records, Sesame seems to think that the form has changed as soon as I navigate to the next record and changes the Last Updated element of the previous (simply viewed but not changed) form.  This, of course, is not acceptable.

Am I overlooking something simple (I hope)?


  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: On Form Change Programming
Reply #1 - Mar 4th, 2005 at 6:55pm
Print Post Print Post  
Hello Spencer,

Take a look at your other programming events particularly the Form On Form Entry event and your Form on Form Exit event to see if they are changing any element values.

-Ray
  

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



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: On Form Change Programming
Reply #2 - Mar 4th, 2005 at 7:24pm
Print Post Print Post  
Ray -

I have carefully gone through every one of my programming events twice now and cannot find anything that should cause an automatic change to the record.

The only on form entry events that are programmed would be to calculate age (or years since an event occured, such as a wedding, etc.)

The code (in this case for age) is simply:

Code
Select All
if Birthdate <> ""

 Age = @year(@date)-@year(Birthdate)-((@month(@date)<@month(Birthdate))
 or (@month (@date) = @month(Birthdate) and @dom(@date)<@dom(Birthdate)))
 



I realize now (and didn't before) that if there were a date in one of the programmed layout elements, this would automatically trigger a "form change."

In any event, this does not seem to be the "problem" because even if a form has no dates on it (and therefore no progamming should be executed) the Last Update field is still modified.

It is, of course, possible that I'm overlooking something in the other programming, but as I said, I checked it twice, very thoroughly each time, and just can't see anything that would automatically change a form (except for the date codes as mentioned above).

  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
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: On Form Change Programming
Reply #3 - Mar 4th, 2005 at 7:44pm
Print Post Print Post  
It seems like your calculated age is overwriting the existing value in the Age.

Why don't you assign the calculated age to a variable and then conditionally update it only if it is needed?

var vAge as Int
vAge = (Your Code)

If Age <> vAge then
Age = vAge

See if this makes any difference.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: On Form Change Programming
Reply #4 - Mar 4th, 2005 at 7:56pm
Print Post Print Post  
Quote:
Code
Select All
if Birthdate <> ""

 Age = @year(@date)-@year(Birthdate)-((@month(@date)<@month(Birthdate))
 or (@month (@date) = @month(Birthdate) and @dom(@date)<@dom(Birthdate)))
 




Hello Spencer,


The "or (@month (@date) = @month(Birthdate) and @dom(@date)<@dom(Birthdate))) " line in your code isn't going to do anything. You should also use @IsBlank() instead of <> "" so

Code
Select All
If Not @IsBlank(Birthdate) Then 



Do you have any unbound combo boxes on this form?

-Ray
  

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



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: On Form Change Programming
Reply #5 - Mar 4th, 2005 at 8:38pm
Print Post Print Post  
Ray -

I've said it before and I'll say it again, you guys are GREAT!

I simply replaced:

Code
Select All
if Birthdate <> ""  



with

Code
Select All
If Not @IsBlank(Birthdate) then  



(I don't think the "then" is needed; however, it makes it clearer for me).

That, alone WOIKED!  I'm assuming that the <>"" was being ignored and, therefore, the programming was always being executed.

That makes me a bit curious though.  If the @isblank is preferred, then why isn't the <>"" simply eliminated from the programming?  Or ... is there an appropriate use of <>"" in preference to @isblank and, if so, could you tell me what criteria should be used to determine which command is chosen?

Also, you said that:

Quote:
The "or (@month (@date) = @month(Birthdate) and @dom(@date)<@dom(Birthdate))) " line in your code isn't going to do anything.


I thought that it was needed to not just consider the current year vs the birth year but also the month and day as well.  Now that I look at it though it seems that there would need to be a "then" portion of the statement (and perhaps an "else" portion, as well).  I know that in Q&A I used similar programming so that the age was accurate "to the day."   It would add a year to an existing age on the birthday only and not a day before. 

Can you suggest how to modify it to accomplish what I want (preferably along the same lines and not using SBasic)?

BY THE WAY, when I went back to my database (after reconciling the DSR file), it was correctly sorted!!!   Grin

You asked whether there were any command buttons but I wonder whether that is still important.  Yes, I have five or six and will be adding more.  The programming for them is executed "on entry" (clicking on the button).   Any special reason for asking (other than for a possible programming problem in one of those layout elements, that might have caused the form change)?

Bharat -

I appreciate your suggestion and it might well work; however, I did not try it.  Since Ray's suggestion made it much easier to change the programming statements (and there were six of them), I simply used it.  Thanks, very much, for helping though.  I appreciate all input and learning alternative ways of accomplishing the same goal.



  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: On Form Change Programming
Reply #6 - Mar 4th, 2005 at 8:45pm
Print Post Print Post  
Quote:
That makes me a bit curious though.  If the @isblank is preferred, then why isn't the <>"" simply eliminated from the programming?  Or ... is there an appropriate use of <>"" in preference to @isblank and, if so, could you tell me what criteria should be used to determine which command is chosen?


@IsBlank is type-safe. In Q&A, under the hood, everything is really a string (text). In Sesame, a date is a date, a number is a number, etc. Therefore, comparing a non-text value like a date to "" (a zero-length string) may not have the intended result. @IsBlank, however, works on any type of data.
  

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



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: On Form Change Programming
Reply #7 - Mar 4th, 2005 at 8:53pm
Print Post Print Post  
Hi "Hammer"

I appreciate the feedback; however, since @isblank is fool-proof and <>"" is not .... I am wondering why it still exists and if there is any occasion when it would be better to use <>"" in preference to @isblank( ).  I have to assume that if it is still available (even though "flawed" so to speak) there must be a reason for continuing to make it available.

Wait a minute:  "Hammer", "Ohio",  "Position: Lanticans."  Are you by any chance Erika Yoxall?  If so, I am extremely eager to speak with you about the upcoming training you are planning.

So, if you are the "right person," I would very much appreciate your letting me know where to call you .. or, of course, you are welcome to call me at (813) 286-8498.
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
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: On Form Change Programming
Reply #8 - Mar 4th, 2005 at 9:00pm
Print Post Print Post  
Quote:
I have to assume that if it is still available (even though "flawed" so to speak) there must be a reason for continuing to make it available.


I guess to make the programming in Sesame backwards compatible with Q&A.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: On Form Change Programming
Reply #9 - Mar 4th, 2005 at 9:01pm
Print Post Print Post  
Quote:
Wait a minute:  "Hammer", "Ohio",  Business - "Lanticans."  Are you by any chance Ericka Yoxall?  If so, I am extremely eager to speak with you about the upcoming training you are planning.


Yep, it's me. I'll be announcing the class schedules and accepting signups soon. If you have specific questions about the classes, my email address is erika@hammerdata.com.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: On Form Change Programming
Reply #10 - Mar 4th, 2005 at 9:03pm
Print Post Print Post  
Computer languages need to support consistent syntax, even where that syntax may not be the ideal. The construct <> (not equal) can have any legal expression on either side of the operator - much like a plus sign "+" can have any numeric on either side, even though using a plus while operating on a negative number results in a subtraction. In other words, we support it because it would be inconsistent not to.
  

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



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: On Form Change Programming
Reply #11 - Mar 4th, 2005 at 9:15pm
Print Post Print Post  
Thanks "Cow" - undstood (I think)!  It seems to me, then, that I am perfectly safe (for Sesame programming purposes) in always "sticking with" @isblank() rather than <>"". 

Erika -  Great - I'm on my way to my e-mail program.
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: On Form Change Programming
Reply #12 - Mar 4th, 2005 at 9:22pm
Print Post Print Post  
Spencer,

I think this is what you want.

 
Code
Select All
If Not @IsBlank(BirthDate) Then
{
	If (@Month(BirthDate) < @Month(@Date)) Or ((@Month(BirthDate) = @Month(@Date)) And (@DOM(BirthDate) <= @DOM(@Date))) Then
	{
		Age = @Year(@Date) - @Year(BirthDate) + 1
	}
	Else
	{
		Age = @Year(@Date) - @Year(BirthDate)
	}
} 



-Ray
  

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



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: On Form Change Programming
Reply #13 - Mar 4th, 2005 at 9:48pm
Print Post Print Post  
Ray -

Something very interesting.  I went back to my Q&Answerman database and apparently I had originally gotten that programming (that I had been using) from a Q&A Technical Bulletin which, I guess, was issued by Symantec.  Apparently, it was "flawed" and subsequently updated in a "Technical Tip" which they also issued.

I also found the Symantic Technical Tip on calculating age that goes into more detail and is easier to understand.

I have not yet tried the programming you provided; however, it "sounds" very familiar, so I am hoping that that is the definitive code I was looking for.

I will make the change right away; however, it may be a while before I can do complex "testing" to validate it under all situations.  Once done, I'll provide feedback.

Geez!  You guys sure are keeping me busy.  I am enjoying Sesame so much (as I did Q&A) that I can't seem to tear myself away from it.   Smiley
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
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: On Form Change Programming
Reply #14 - Mar 4th, 2005 at 10:51pm
Print Post Print Post  
For every rule there is an exception Spencer:
Don't always use @IsBlank. 

That only works for Layout Elements.

Still need to use <>"" for variables.
---------------------------------
From the supplement documentation, page 22:

@IsBlank(element)
Type: Miscellaneous
Parameters:Layout Element as ElementRef
Returns: Boolean
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print