Home » Developer & Programmer » Forms » Cannot get querying to work? (Forms, 6i, Windows 7)
Cannot get querying to work? [message #535820] Fri, 16 December 2011 08:31 Go to next message
ericr
Messages: 22
Registered: January 2006
Junior Member
I have a form that has a master detail section and the under that a multi record block for the children of that master item. What I am trying to accomplish is that when one of the children are highlighted and my "Drill Down" button is pressed the form is cleared, put into query mode, the child from the highlighted row gets put into the master section and the query executed.

Here is what I have so far (in a button pressed trigger):

DECLARE
        -- variable to save selected child
	v_cur_child varchar(50);
	
BEGIN
        -- get the value for the item where cursor is
	GO_RECORD(:SYSTEM.CURSOR_RECORD);

        -- save value to variable
	v_cur_wi_code := :BLOCK2.WI_CODE;

	Clear_Form;

        -- Go to the parent block
	GO_BLOCK('BLOCK1');	

        -- Enter query mode
	ENTER_QUERY;

        -- set master record value to saved child value        
	:BLOCK1.WI_CODE := v_cur_child;

        execute_query;
END;


BLOCK1 (master section) has query allowed = YES, insert and updated allowed = NO. The WI_CODE item within BLOCK1 has query allowed = YES, insert allowed = YES, and update allowed = NO.

The child section (BLOCK2) has query allowed = YES, insert and update allowed = NO. The WI_CODE item within BLOCK2 has query allowed = YES, insert allowed = YES, and update allowed = NO.

The problem is that no matter what I do the following 2 problems occur:

1. The saved value nevers get put into the master section. I know the value is being saved because I used MESSAGE to output for verification.

2. I keep getting the error: "FRM-41051: You cannot create records here."

Where have I gone wrong. The steps above seem logical to me. I have tried changing the order in which I do things but the result is the same.

Any ideas?

Thanks...
Re: Cannot get querying to work? [message #535832 is a reply to message #535820] Fri, 16 December 2011 09:05 Go to previous messageGo to next message
cookiemonster
Messages: 13926
Registered: September 2008
Location: Rainy Manchester
Senior Member
At what exact point do you get the FRM error? use messages to work it out.
Re: Cannot get querying to work? [message #535837 is a reply to message #535832] Fri, 16 December 2011 09:52 Go to previous messageGo to next message
ericr
Messages: 22
Registered: January 2006
Junior Member
I get the error when I "exit_form". I just cannot understand why the value will not fill in.
Re: Cannot get querying to work? [message #535839 is a reply to message #535837] Fri, 16 December 2011 09:57 Go to previous messageGo to next message
cookiemonster
Messages: 13926
Registered: September 2008
Location: Rainy Manchester
Senior Member
TRy using a pre-query trigger instead of enter-query mode.
Re: Cannot get querying to work? [message #535841 is a reply to message #535839] Fri, 16 December 2011 10:14 Go to previous messageGo to next message
ericr
Messages: 22
Registered: January 2006
Junior Member
I don't understand. I don't want this to happen before every query. I just want it to happen when someone clicks the "Drill Down" button.
Re: Cannot get querying to work? [message #535846 is a reply to message #535841] Fri, 16 December 2011 10:30 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
In the WHEN-BUTTON-PRESSED trigger (on the "Drill Down" button), use current item's value in SET_BLOCK_PROPERTY(ONETIME_WHERE). Something like this:
-- WHEN-BUTTON-PRESSED
set_block_property('block1', onetime_where, 'wi_code = :block2.wi_code');
go_block('block1');
execute_query;
Re: Cannot get querying to work? [message #535849 is a reply to message #535846] Fri, 16 December 2011 10:42 Go to previous messageGo to next message
cookiemonster
Messages: 13926
Registered: September 2008
Location: Rainy Manchester
Senior Member
You could make it work with pre-query by storing the value in the button assigning it in pre-query if populated and then clearing it in post-query.
Littlefoot's way is better though. I keep forgetting about onetime_where.
Re: Cannot get querying to work? [message #536200 is a reply to message #535849] Mon, 19 December 2011 13:55 Go to previous message
ericr
Messages: 22
Registered: January 2006
Junior Member
Thanks! That worked!
Previous Topic: Read Image Through URL
Next Topic: Temporarily pause Forms execution
Goto Forum:
  


Current Time: Tue Jul 09 23:32:14 CDT 2024