Hello,

I have a form with a DB Grid linked to a work table. The form includes a button to add items selected from a list. The button updates the worktable and a master table. The form works when I run it within the form designer - that is, the data in the grid reflects the current state of the working table - and it adds items from the list when the button is pressed. However, the form does not work when called from the database explorer or the R> prompt with 'enter using' (with data present in the work table). It also does not work when called from another form with the state of the work table being set by the calling form and the appropriate 'enter using' or 'edit using' command being issued.

Any ideas?

Thank you

Karl Herrick

The following is the code for the button.

SET VAR vcurrentproject = ''
SET VAR vprotodesign = ''
SET VAR vissuchroomexists INTEGER = 0
SET VAR issuchroomexists INTEGER = 0
SET VAR vmsgpreface TEXT = ''
SET VAR vmsgpostface TEXT = ''
SET VAR vmsg TEXT = ''
SET VAR vspaceroomtypeid INTEGER = 0
SET VAR ispaceroomtypeid INTEGER = 0
SET VAR iprotodesign INTEGER = 0

SELECT projectid INTO vcurrentproject FROM currentproject WHERE COUNT=LAST
SELECT protodesignname INTO vprotodesign INDICATOR iprotodesign +
FROM currentproject WHERE COUNT=LAST

-- The Following Line relies on Uniquenness of Room Type Names
SELECT COUNT(*) INTO issuchroomexists FROM currentspaceroom +
WHERE spaceroomname = .vaddingroom
IF  issuchroomexists > 0 THEN
 -- we only add room if it is not already there

 --  SET VAR vmsg TEXT = 'That room already exists in current project'
 SET VAR vmsgpreface = 'Room "'
 SET VAR vmsgpostface = '" already exists in the Current project.'
 SET VAR vmsg = (.vmsgpreface+.vaddingroom+.vmsgpostface)
PAUSE 2 USING .vmsg CAPTION 'ERROR' ICON serious OPTION themename Diamond BLUE
 RETURN

ENDIF

SELECT spaceroomtypeid INTO vspaceroomtypeid INDICATOR ispaceroomtypeid +
FROM spaceroomtypes WHERE spaceroomtypename =.vaddingroom

--
--PAUSE 1 USING 'before INSERT INTO spaceroom...' CAPTION 'Exists' BUTTON 'Ok'

INSERT INTO spaceroom +
( spaceid, spaceroomtypeid, spaceroomname, protodesignname ) +
VALUES +
( .vcurrentproject , .vspaceroomtypeid , .vaddingroom , .vprotodesign )

--
--PAUSE 1 USING 'before INSERT INTO currentspaceroom...' +
--CAPTION 'Exists' BUTTON 'Ok'

INSERT INTO currentspaceroom +
( spaceroomid, spaceid, spaceroomtypeid, spaceroomname, protodesignname ) +
SELECT spaceroomid, spaceid, spaceroomtypeid, spaceroomname, protodesignname + FROM spaceroom WHERE spaceid=.vcurrentproject AND spaceroomtypeid=.vspaceroomtypeid AND spaceroomname=.vaddingroom

WRITE '#TIME=', .#TIME
WRITE 'vAddingRoom=', .vaddingroom
WRITE 'vCurrentProject=', .vcurrentproject

RECALC TABLES
RECALC VARIABLES
PROPERTY maingrid refreshlist 'TRUE'
SCREEN RESTORE ON

RETURN


Reply via email to