PDA

View Full Version : OnKey


ABC123

Duane Pederson
03-10-2005, 08:42 AM
Morning

I have 1 form open, it's in View mode, and it has focus, but I can't get any reaction from the form's OnKey event.

I tried my own scripts and nothing at all happens.
I copied and pasted a code from a Cal Locklin message board post:

IF a_user.key.value = "{ESC}"
IF parentform.mode_get() = "View"
a_user.key.handled = .T.
IF a_user.key.event = "down"
parentform.close()
END IF
END IF
END IF

Nothing

I added 'then' after each IF statement

Nothing

I don't see anything in the form's properties that would impede this event. I have done OnKey stuff in V6, but I can't seem to do it in V5.
Any idea what I'm doing wrong?

Thanks
Duane

Cheryl Lemire
03-10-2005, 09:13 AM
Duane,

Based on what you have said in your message, pressing the 'esc' key should close the form. I use the same exact code on some forms and they work fine in both V5 and V6. Maybe you can strip down the db and attach the table/form where you have tried this in V5 with no results. Since I am unable to duplicate your reported problem, that leads me to think that it is something specific to your form.

Cheryl

Stan Mathews
03-10-2005, 09:42 AM
I just tested the code in V5 and it worked fine - when the form is in view mode. Otherwise it does nothing. I would suspect your form is not in view mode.

Duane Pederson
03-10-2005, 10:00 AM
Thanks to both for checking this out

I know it's weird and has to be something I have in the form. It's a farily big form based on a set so I'll have to try to take the time tonight to strip it down for transportation.
I 'm not actually trying to use the form close on the 'ESC' key, I'm trying to get a calc or var field to show me if the form has the allow_changes On or OFF for editing. Doing a trap on the F3 key push and refreshing the form to display the calc field wasn't working. So I tried Cal's script for closing; it didn't work either. So no OnKey event works at all for this form.
I've compacted it right into the desk and the form indicates it is in view mode, so I'm still confused. Unless the form is corrupted? I'll try that approach and see what's up

Thanks
Duane

Tom Cone Jr
03-10-2005, 10:47 AM
Does your Data Entry Style impact this?

-- tom

Cheryl Lemire
03-10-2005, 10:47 AM
Duane,

Feel free to zip up your db and email it to me if this will save you time from stripping it down. Be sure to give me steps to duplicate your problem so that I do not waste time looking around to find the issues.

Good luck
Cheryl

Duane Pederson
03-10-2005, 11:07 AM
Thanks Cheryl, just need to find some time yet to copy it and dump a bunch of records

Tom, it's in modeless data entry. I haven't tried to change it. In fact I can have a dropdown previous value lookup field selected ready to change, form still in view mode, and still the OnKey doesn't do anything.

Thanks
Duane

Duane Pederson
03-10-2005, 03:16 PM
Finally

Here is the zipped app. The photos folder is just for the display on the photo tab.
It is an inhouse tool we use and is an ongoing work project.

The form in question is the main_tab, the OnFetch sets the form to allow_changes(.f.) so we keep screwups down.

What I am trying to accomplish with these posts is to refresh the form on pushing the F3 key, so the calc field 'editmode' shows "Yes" or "No" depending on the edit state of the form. The calc field changes accordingly when you push F5, but I want it to do that automatically.
All the ui_msg_boxes in the form's OnKey code is just so I can see where the code gets to. But it doesn't even start.

It has to be something simple that I have wrong, but ....

Thanks
Duane

Cheryl Lemire
03-10-2005, 03:35 PM
Duane,

I have just started testing, but it is definitely tied to the specific form itself because I was successfully able to get the ESC key to close the form using the customer form. I will let you know what else I find.

Unless of course, somebody is much faster than I am :)

Good luck
Cheryl

Cheryl Lemire
03-10-2005, 04:01 PM
Duane,

Hopefully somebody else can also take a look at this. The form is definitely complicated and so far I cannot see real quick what is causing the conflict with the OnKey event.

I can tell you this .... something that is really odd .... when I open the form in view mode, I get an error .... not an executable file. This is probably the cause of the OnKey event not working, but I am still trying to figure out what is causing that error.

Cheryl

Duane Pederson
03-10-2005, 04:19 PM
Thanks for looking Cheryl

I don't recall having that error recenly with this particular app
Maybe cause you are missing the Photos folder for the Photos tab. I'll try to attach that to this post. It goes into the same folder you have the adb in.

Thanks
Duane

Cheryl Lemire
03-10-2005, 04:37 PM
Duane,

I did not take your attachment. However, once I deleted the sub form on the photos tab, the ESC OnKey event works fine. I did not test your OnKey, but verified that without your subform the OnKey functions properly.

Now you get to test your other OnKey events as well as determine what the problem is with the sub form.

Good luck
Cheryl

Cheryl Lemire
03-10-2005, 04:40 PM
Duane,

On another note, the 'view' calculated field you have in the upper right hand corner is an invalid expression. You may want to take a look at that as well.

Good luck
Cheryl

Duane Pederson
03-10-2005, 07:06 PM
Thanks Cheryl

Yeah, I saw that invalid message but it works. I just thought it was a bad message.

Well you're right. It has to do with the subform. I took it out and the OnKey works. I put in another subform but used a default form based on another table, the OnKey did not work.

I did get over what started all this; used F11 instead of the pgm F3, to do the allow/disallow changes and to refresh the form calc fields.

Now, just to figure out why the subform gives grief. May have to have the photos display on a separate opening form (should have done a lot of that in the first place)

Thanks again
Duane

Cheryl Lemire
03-10-2005, 07:23 PM
Duane,

It is not a bad message, it may work, but that would be a bug. I would definitely look at changing your calc field so that it is a valid expression.

Instead of using a sub form, try to put the data you want on the tab and see if that resolves the sub form issue.

Good luck
Cheryl

Stan Mathews
03-10-2005, 07:40 PM
"Not an executable file" is usually either caused by

a completely commented out abasic event script

or

a udf call without the necessary parameter(s)

Cheryl Lemire
03-11-2005, 03:45 AM
Thanks Stan. Since Duane was not getting that error and only I was, your explanation makes sense. I was commenting out a lot of code and removing objects as a process of elimination trying to locate the cause of the OnKey error.