Preventing or creating action on END-KEY

I have a process that lists users of my databases (QAD & EAM). I am running this process inside of my EAP application, QAD. The QAD side works well as the QAD database is the DICTDB. However, I need to switch the DICTDB to EAM, when listing those users. I have everything working except for one issue that I have struggled with for some time. I cannot switch the DICTDB back to QAD, if the user presses F4. I have tried a number of things, but so far no go.

I am looking to either disable the F4 key, forcing the user to exit using an exit event, which includes the switch, that I have provided or to try to create an event for the F4 key that performs the switch. Here is the snippet of the code i have been fumbling with:
.
.
.
[FONT=r_ansi][FONT=r_ansi]FORM
usr-select-b SKIP(1)
select-usr x-usr
SKIP(1)
WITH FRAME usr-select-f CENTERED.
[/FONT].
.
.
ENABLE select-usr x-usr WITH FRAME usr-select-f.
[/FONT].
.
.
[FONT=r_ansi]ON CHOOSE OF x-usr DO: /*x-usr button labeled as "LEAVE" */
MESSAGE "LEAVING MLS DATABASE" VIEW-AS ALERT-BOX.
DISCONNECT mls.
CREATE ALIAS "DICTDB" FOR DATABASE qaddb.
END.
[/FONT]
[FONT=r_ansi]IF KEYFUNCTION(lastkey) = "END-KEY"
OR KEYFUNCTION(lastkey) = "END-ERROR" THEN DO:
MESSAGE "CANCELLING DATABASE DISCONNECT"
VIEW-AS ALERT-BOX.
DISCONNECT mls.
CREATE ALIAS "DICTDB" FOR DATABASE qaddb.
END.
[/FONT].
.
.
[FONT=r_ansi]ON CHOOSE OF select-usr DO:
curr-usr = ROWID(_Connect).
FIND _Connect WHERE ROWID(_Connect) = curr-usr NO-LOCK NO-ERROR.
IF AVAILABLE _Connect THEN DO:
RUN Store-usr-2-remove(_Connect-Usr).
END.
ELSE MESSAGE "No Record Found" VIEW-AS ALERT-BOX.
END.
[/FONT].
.
.
[FONT=r_ansi]CREATE ALIAS "DICTDB" FOR DATABASE mls.
OPEN QUERY usr-select-q FOR EACH _Connect
WHERE _Connect-Type = "SELF"
BY _Connect-Name.
ENABLE ALL WITH FRAME usr-select-f.
WAIT-FOR CHOOSE OF x-usr OR CLOSE OF FRAME usr-select-f.


Anyway...
I cannot get the F4 key to yield me the MESSAGE and when I go to the PE it shows mls as the active db.

Please help.
[/FONT]
 

LarryD

Active Member
did you try:

Code:
ON END-ERROR OF FRAME [FONT=r_ansi][SIZE=2]usr-select-f DO:[/SIZE][/FONT]
[FONT=r_ansi][SIZE=2]MESSAGE "CANCELLING DATABASE DISCONNECT" 
        VIEW-AS ALERT-BOX.
    DISCONNECT mls.
    CREATE ALIAS "DICTDB" FOR DATABASE qaddb.
END.[/SIZE][/FONT]
 
Top