At 08:26 AM 1/8/2016, TOM HART wrote:

I can get the action to fire both on before and on after but I cannot get
the form to close. I have a watch variable that sets to 0 if the password
fails and I've tried on entry to the first field if vwatch  =0 then
closewindow
endif

but that does not close form



You CANNOT call (execute) a Custom Form Action in On Before Form Start EEP.

Carefully TRACE the form to see the exact behavior.

Having stated that ...

If you wish to validate a user access by asking a password as On Before Form
Start EEP, close the form if not a valid password, then, use the following
technique.

-- A very simple example
-- Use the following code as On Before Form Start EEP
-- January 8, 2016
-- Start here ...
   SET VAR vPassword TEXT = NULL
   SET VAR vOK TEXT = NULL
   SET VAR vEndkey TEXT = NULL
   SET VAR vCaption TEXT = 'Application Security'
LABEL GetPassword
   CLS
   DIALOG 'Enter Password' vPassword=29 vEndKey PASSWORD +
   CAPTION .vCaption ICON WINDOWS +
   OPTION WINDOW_BACK_COLOR WHITE +
   |MESSAGE_BACK_COLOR WHITE +
   |MESSAGE_FONT_NAME Tahoma +
   |MESSAGE_FONT_COLOR RED +
   |MESSAGE_FONT_SIZE 12 +
   |INPUT_BACKGROUND_COLOR YELLOW +
   |INPUT_FONT_NAME Tahoma +
   |INPUT_FONT_COLOR RED +
   |INPUT_FONT_SIZE 12 +
   |BUTTON_YES_CAPTION &Continue +
   |BUTTON_YES_COLOR WHITE +
   |BUTTON_YES_FONT_COLOR GREEN +
   |BUTTON_NO_CAPTION C&ancel +
   |BUTTON_NO_COLOR WHITE +
   |BUTTON_NO_FONT_COLOR RED
IF vPassword IS NULL OR vEndKey = '[Esc]' THEN
   SET VAR vOK = 'No'
   GOTO Done
ENDIF
IF vPassword = 'whatever' THEN
   SET VAR vOK = 'Yes'
   GOTO Done
ELSE
   CLS
   PAUSE 2 USING 'Invalid Password Entered!' +
   CAPTION .vCaption ICON WARNING +
   BUTTON 'Press any key to re-enter password'+
   OPTION BACK_COLOR WHITE +
   |MESSAGE_FONT_NAME Tahoma +
   |MESSAGE_FONT_COLOR RED +
   |MESSAGE_FONT_SIZE 11
   SET VAR vPassword = NULL
   GOTO GetPassword
ENDIF
LABEL Done
   CLEAR VARIABLES vPassword,vEndKey,vCaption
   RETURN
-- End here ...

And, use the following code as On After Form Start EEP:

-- Start here ...
IF vOK = 'No' THEN
   CLOSEWINDOW
ENDIF
   CLEAR VARIABLES vOK
   RETURN
-- End here ...

That should provide you with a very simple technique to validate the access
and then close the form accordingly.

Note:

Make sure to change the QUOTE settings used in this example based upon your
database QUOTE settings, if necessary.

Too overwhelming? Hopefully not!

Very Best R:egards,

Razzak


Reply via email to