Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formset confusion

Status
Not open for further replies.

kenndot

Programmer
Joined
May 15, 2001
Messages
316
Location
US
I'm working on an app with formsets, no I didn't build it, just fixing it. I have a formset with many forms in it and this is what's happening.

I have a field which the user enters a number and hits tab or the enter key and the other fields are filled in automatically. Well, when the enter key is hit, a different form within the formset is called into focus, and the click event of that form runs (which runs a report). Then the program crashes.

I've checked the point where the wrong form gets the focus and gets loaded and there's nothing there calling this other form. I've also checked to make sure that there isn't any ON KEY LABEL... for the enter key corresponding to that (wrong) form and for the life of me I can't figure out why, even if the form is called in error, why the click event of a button would run.

Any ideas/suggestions would be great as I'm at a bit of a loss.
 
Kenndot,

This may be related, sorry if not, but the first VFP project I worked on used a formset (come on, it was my first one![blush]) and I kept having a problem where, if one form was on top of another and it didn't have focus and I clicked on an object on it, it would act upon the form beneath it - doh!

I guess you aren't in a position to make separate forms to replace the formset?

Hope that helps,

Stewart
 
I will look into that. I'm not clicking an object on the form though, I'm only hitting the enter key and that sets off the form underneath's click event somehow. I'm using the event tracking right now to see what is happening right before this happens and there is NO code in the events that are called right before the wrong form is opened.

No, this is a huge app and we aren't even thinking about changing everything but rest assured, nobody uses these darn things anymore here!
 
Have you looked to see if the form or formset or the control you're concerned with are subclassed from another class where there is some code in the parent class? Dave Dardinger
 
As you mentioned, I checked the classes that are on the form and none of them appear to have any effect on hitting the enter key, but thanks for the suggestion. I'm willing to try anything at this point.

Is there any strange event sequence that goes on with formsets? I have checked out the manual and what they claim the event sequences are but this program is not following what the book says.

I turned on the event sequence log and noticed that just completely out of the blue, the forms OK button click event just fires without prompting. Very strange. Any more suggestions on what I should check on are appreciated.


 
Have you checked that there are no controls (specifically, command buttons) that have the DEFAULT property set .T.? If there is one, it will fire its CLICK event any time ENTER is pressed.

On a side note...would that happen on a different form in a formset? See if the second form's button has its DEFAULT property set .T. also.

Ian
 
ChPicker,

I checked and yes the default property is set to true on the form that is incorrectly popping up, HOWEVER... That just confirms that somehow that form is truly getting the focus when it shouldn't. Do you have any idea why the enter key when pressed on a different form (within the same formset) would open up another form? I've checked and had other people check as well, there is NO CODE that opens this form.

thanks!
 
Chpicker,

Hey THANKS! I don't understand why the default property on one form would affect another form even if they ARE in the same formset, but when I changed the default property to false for the form that was showing in error, the problem went away.

It doesn't make much sense to me, but it worked! THANKS!!
 
That seems to be the way formsets work. I just created a test set, and it did the same thing. In fact, if you TAB through your form, you'll find that when it reaches the end of your first form's tab order, the focus will jump to the next page! It works going back, too, using SHIFT+TAB (or when you get to the end of the second page)

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top