I have a form that runs fine either in ENTER or EDIT mode from the
database explorer or the R>. When calling the form from a group bar
menu in another form using ENTER using formname, it's fine also.
However, when I run it using EDIT USING formname, I get an access
violation every time I close the form. I've narrowed it down to the ON
CLOSE EEP (see below). If I take out the IF vnum1 = .vnum2 THEN section
up through the ELSE, I don't get the access violation. (I've also tried
IF vnum1 <> .vnum2 and reversing the logic - it didn't help). Here's
the eep, the offending section is preceded by >>>>>, any help would be
appreciated.
DELETE ROWS FROM colorformulas WHERE pigment IS NULL AND pigorder IS
NULL
DROP tcolcheck
CREATE TEMP TABLE tcolcheck (tnumcol TEXT 12, tformula TEXT 200)
(I then SET all variables used in cursors to TEXT = NULL)
DECLARE cnumcol CURSOR FOR SELECT DISTINCT numcol FROM colornumbers
ORDER BY numcol
OPEN cnumcol
FETCH cnumcol INTO vnumcol
WHILE SQLCODE <> 100 THEN
DECLARE c1 CURSOR FOR SELECT numcol, formline FROM formulaview WHERE
numcol = .vnumcol
OPEN c1
FETCH c1 INTO vanumcol, vformline
WHILE SQLCODE <> 100 THEN
SET VAR vaformline = (.vaformline & .vformline)
FETCH c1 INTO vanumcol, vformline
ENDWHILE
DROP CURSOR c1
INSERT INTO tcolcheck tnumcol, tformula VALUES .vnumcol, .vaformline
SET VAR vaformline = NULL
FETCH cnumcol INTO vnumcol
ENDWHILE
DROP CURSOR cnumcol
SELECT COUNT(tnumcol) INTO vnumcount FROM tcolcheck t1, tcolcheck t2
WHERE t1.tnumcol <> t2.tnumcol AND t1.tformula=t2.tformula
SET VAR vnum1 TEXT = '1'
SET VAR vnum2 TEXT = '1'
IF vnumcount > 1 THEN
SELECT tnumcol INTO vnum1 FROM tcolcheck t1, tcolcheck t2 WHERE
t1.tnumcol <> t2.tnumcol AND t1.tformula = t2.tformula AND COUNT = 1
SELECT tnumcol INTO vnum2 FROM tcolcheck t1, tcolcheck t2 WHERE
t1.tnumcol <> t2.tnumcol AND t1.tformula = t2.tformula AND COUNT = 2
ENDIF
>>>>>IF vnum1 = .vnum2 THEN
DROP tcolcheck
CLEAR ALL VAR
RETURN
ELSE
>>>>this section by itself, without the if,then, else works fine. But I
need the IF, then else!
SET VAR vmsg = (.vnum2 & 'has the same formula as' & .vnum1 +
(CHAR(013)) + 'It will be deleted')
PAUSE 2 USING .vmsg CAPTION ERROR icon attention
DELETE ROWS FROM colornumbers WHERE numcol = .vnum2
DELETE ROWS FROM colorformulas WHERE numcol = .vnum2
ENDIF
DROP tcolcheck
CLEAR ALL VAR
RETURN