I'm having a strange problem with typecasting.  I was hoping someone else on the list could try and duplicate the problem for me, or point out where I am going wrong.  The problem is especially strange because if I have SET TRACE ON in my code, the problem does not happen.
    I have a form which in certain circumstances requires the user to enter a date and time.  I want to compare the date and time entered to the current time to make sure that the time entered is in the future.  I use a DIALOG command with a popup.  I have put the code below.
    If I run the EEP without a SET TRACE ON in the code, then I get error 2158 (-ERROR- _expression_ does not return a valid DATETIME.), followed by error 3031 (-ERROR- SET Error Command).
    If I run the code with a SET TRACE ON statement, the code executes fine.  It even executes fine if I never step through the code and just press the green triangle/play button as soon as the trace window opens.
    I am running 7.6.5.31229
                                                       Thanks,
                                                       Jason

SET VAR vmessage TEXT = NULL
SET VAR vdans TEXT = NULL
SET VAR vdkey TEXT = NULL
SET VAR vtempdt DATETIME = NULL
SET VAR vreqdatetime TEXT = NULL

SET VAR vmessage = 'Double click to show a calendar and clock.'
SET VAR vdans = NULL
WHILE vdans IS NULL THEN
  DIALOG 'Please enter the date and time this request is needed.' vdans vdkey 1 CAPTION 'Date and Time Needed' ICON question OPTION popup_enabled ON | popup_dialog_type DATETIME | dialog_edit_hint &vmessage
  IF vdans IS NOT NULL THEN
    SET VAR vtempdt = .vdans
  ENDIF
  IF vtempdt IS NOT NULL THEN
    IF vtempdt < .#now THEN
      PAUSE 2 USING 'Please enter a time in the future.' CAPTION 'Invalid Time' ICON error
      SET VAR vdans = NULL
    ENDIF
  ELSE
    SET VAR vdans = NULL
  ENDIF
ENDWHILE
SET VAR vreqdatetime = .vdans

PAUSE 2 USING .vreqdatetime

CLEAR VARIABLES vmessage, vdans, vdkey, vtempdt, vreqdatetime

RETURN
-- 
Jason Kramer
University Archives and Records Management
002 Pearson Hall
(302) 831 - 3127 (voice)
(302) 831 - 6903 (fax)




Reply via email to