Hot Topic (More than 10 Replies) OnFormChange Event Problem (Read 2203 times)
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
OnFormChange Event Problem
Mar 26th, 2004 at 4:08am
Print Post Print Post  
There is a problem that occurs while using the F6 window to change values in a subform (table view).

If you press F6, make a change to the value, and press F6 again to close the window, OnFormChange events do NOT fire when leaving the element as they should and do when in the main form of the subform db.

Has anyone else seen this?
  


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: OnFormChange Event Problem
Reply #1 - Mar 27th, 2004 at 3:10pm
Print Post Print Post  
Mark or Erika,

Have you had a chance to verify this?
  


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: OnFormChange Event Problem
Reply #2 - Mar 27th, 2004 at 3:27pm
Print Post Print Post  
Yes - just now. It is confirmed. The on form change does not fire for a table view subform if edited with F6 editor. The on element change, on the other hand, does seem to fire.
  

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: OnFormChange Event Problem
Reply #3 - Mar 27th, 2004 at 3:52pm
Print Post Print Post  
Quote:
The on element change, on the other hand, does seem to fire.

I don't see this working either. Sad

I just checked On Element Exit.  That seems to be working perfectly. Grin
  


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: OnFormChange Event Problem
Reply #4 - Mar 27th, 2004 at 4:22pm
Print Post Print Post  
I just tried it in the Countries.db application. I put the on element change event:

City = City + " A"

in the Population LE of the Cities subform. On leaving the population field after changing it with the F6 editor - it seemed to fire without fail. Admittedly, this is a very simple case.

Can you provide more detail?
  

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: OnFormChange Event Problem
Reply #5 - Mar 27th, 2004 at 9:59pm
Print Post Print Post  
Mark,

This is the code that I used to test with. It was placed in the "[Form Name] :: On Form Change" event.

Code
Select All
System ID = @FormFieldValue("DBS Commissions Form", "System ID", 0)
// This code was originally in OnFormChange, but it did not function if F6 was used to
// edit an element.  I also put it in OnElementChange.  It didn't work there either.
// So I put it in OnElementExit.  It seems to work perfectly there.
 


As I'm sure you can tell, the code is to set the Subform's System ID to match the Main Form's System ID. (I'm using relational linking for this subform.)

I would enter the subform, press the down arrow to display a new line/record, move to any element, press F6, make a change, press F6 again, then move out of the edited element either to another element, another line in the subform, or to the main form. In any case, it would not fill the System ID element.

I noticed that after closing the edit window, if rather than doing one of the above, I were to move to another element and begin to type, the System ID would update upon the 1st keystroke.  Now, that's different than the usual (except for On Element Immediate Change).  Usually, you make the change to an element, and upon exiting it, the program recognizes at that time that something has changed, and would fire.

I hope this helps. If you have more questions, let me know.
  


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: OnFormChange Event Problem
Reply #6 - Mar 27th, 2004 at 10:18pm
Print Post Print Post  
I just discovered something else.  When you test my previous post, don't click twice on the element that you are about to edit with F6. Just click once, so the element is highlighted in gray, not white.

The code will work if the element is white, but not if it is gray.

  


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: OnFormChange Event Problem
Reply #7 - Mar 28th, 2004 at 5:15am
Print Post Print Post  
Quote:
Code
Select All
// So I put it in OnElementExit.  It seems to work perfectly there.
 



Mark,

Well... not so perfectly.

Within the subform: if I down arrow to a new line (blank record) and up arrow without making any changes, that blank record disappears (programming should be filling System ID upon exiting the element, but it's not). Yet, when I save the main record with Ctrl-10 or F10, and return with F9, that unwanted subrecord is there with the System ID element filled.

Now forget all that. Smiley

Here's the root of the problem: after some testing, I found that the On Element Exit event is not firing every time I exit an element. If I click on an element (highlighting it in gray), then click on another element (same gray highlight), no event occurs until I click on a different subrecord or the main form. In the case of the main form, it fires TWO times. (Erika posted a message indicating that WriteLn may cause multiple firings, so I tested this without using it. I added one "*" to a text field at each firing.)

The only way to activate the element exit event while staying on the same subrecord, is to click twice on one element (changing the background to white), and then click twice on another element. The event only fires when the 2nd element's background turns white, rather than when you exit the 1st element.

I understand that being highlighted in gray maybe wasn't intended to be considered having "entered" an element, but leaving that element after having a white background should definitely constitute an element exit. Yet, you need to begin editing another element, making it's background white before the exit event of the previous element will fire.

Does that make sense?

Also, if you edit a subform element, then click straight to a main form element, your edits are lost.  Other methods of leaving the element (e.g. F10, Ctrl-F10, ArrowDown, Tab) retain them properly.

FYI:
To avoid confusion, I removed all other programming in the subform layout and the main layout to be sure I wasn't getting strange results due to other events interfering.
  


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


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: OnFormChange Event Problem
Reply #8 - Mar 28th, 2004 at 5:32am
Print Post Print Post  
My problem of not being able to post to a subrecord may be related to this. Maybe this is why the few elements that actually do post to the subrecord, end up posting to the wrong elements.

CRAZY!

Steve
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: OnFormChange Event Problem
Reply #9 - Mar 28th, 2004 at 1:23pm
Print Post Print Post  
Quote:
The only way to activate the element exit event while staying on the same subrecord, is to click twice on one element (changing the background to white), and then click twice on another element. The event only fires when the 2nd element's background turns white, rather than when you exit the 1st element.


I'm not seeing this in Countries.db. I put:

City = City + "A "

in the element exit of Population and it is firing as soon as I leave population, whether by single click of the mouse or by keyboard. The symptoms you describe sound like 1.0 or 1.0.1 - have you upgraded to 1.0.2?

I am seeing the bug wherein clicking on the main form from the "on element exit" field of the subform causes the on element exit event to fire twice.
  

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: OnFormChange Event Problem
Reply #10 - Mar 28th, 2004 at 2:36pm
Print Post Print Post  
Marc,

Yes, I am using 1.0.2.

You're right, it works ok if the code is in "Population :: On Element Exit". But try it in "Cities :: On Element Exit". Also notice that some times the space after the "A" is maintained, and sometimes it is not.
  


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: OnFormChange Event Problem
Reply #11 - Mar 28th, 2004 at 2:57pm
Print Post Print Post  
Okay - I see it now. You have the On Element Exit code on the SubForm itself so it will fire no matter which element you exit?
  

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: OnFormChange Event Problem
Reply #12 - Mar 28th, 2004 at 5:59pm
Print Post Print Post  
Quote:
Okay - I see it now. You have the On Element Exit code on the SubForm itself so it will fire no matter which element you exit?

Yes.

My original problem was On Form Change events were not working with F6 edits. So the closest alternative to that was to use On Element Exit for the form itself to get code to fire every time I left any element.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged