Home » Developer & Programmer » Forms » Control Item help
Control Item help [message #238722] Sat, 19 May 2007 13:15 Go to next message
lune
Messages: 27
Registered: August 2006
Location: UAE
Junior Member
I have created a control item to show the department name in the employee form instead of showing the department ID


The problem is when I want to insert a new employee record I want the user to choose the department name and according the chosen department name the department ID will be inserted in the employee table for the new employee.

Do you have anyway to do it?

I tried to write this code in the insert button but it didn’t work ???

DECLARE
	DEPT_NO DEPARTMENTS.DEPT_ID%TYPE;
BEGIN
	SELECT DEPARTMENTS.DEPT_ID INTO DEPT_NO
	FROM DEPARTMENTS
	WHERE DEPARTMENT_NAME = :EMPLOYEES.DEPT_NAME;
	
		FORMS_DDL('INSERT INTO DNRD_EMPLOYEES VALUES (:EMPLOYEES.EMP_ID, DEPT_NO, EMPLOYEES.EMP_NAME, EMPLOYEES.EMP_EMAIL)');
COMMIT;
		message('The record has been inserted successfully');
END;


Waiting your help
Re: Control Item help [message #238749 is a reply to message #238722] Sat, 19 May 2007 15:38 Go to previous messageGo to next message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Why all that pain? Why didn't you create a display item (to show department name) and attach a list of values to the department ID item which would populate both ID and name?

Regarding your code, why did you use ":employees" once and "employees" for the rest of the columns in the FORMS_DDL? Also, it would be a good idea to explain what happens with the code, possibly an error message. Saying that "it doesn't work" isn't much descriptive.
Re: Control Item help [message #238786 is a reply to message #238722] Sun, 20 May 2007 00:14 Go to previous messageGo to next message
lune
Messages: 27
Registered: August 2006
Location: UAE
Junior Member

Thank you for your reply LittleFoot

I did it in another way, I created a list item on the department ID showing the department name and department ID as a value.

But I'm getting this error

FRM-40202 fields must be enterd


----
lune
Re: Control Item help [message #238820 is a reply to message #238786] Sun, 20 May 2007 03:32 Go to previous messageGo to next message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
It appears that you didn't enter a value into a "required" item. Check the code and fix it.
Re: Control Item help [message #239287 is a reply to message #238722] Mon, 21 May 2007 23:08 Go to previous messageGo to next message
lune
Messages: 27
Registered: August 2006
Location: UAE
Junior Member
Hello LittleFoot

I have created a record group for the list but the same error is appearing FRM-40202 fields must be enterd

Here is the code and Im not leaving any record empty

DECLARE
	INSERT_MESSAGE NUMBER;

BEGIN
	
	
	IF (:EMPLOYEES.DEPARTMENT_DEPT_ID IS NULL OR :EMPLOYEES.EMP_NAME IS NULL OR :EMPLOYEES.EMP_NO IS NULL OR :EMPLOYEES.EMP_EMAIL IS NULL) THEN
				SET_ALERT_PROPERTY('ERROR_ALERT',ALERT_MESSAGE_TEXT,'You must enter all the fields !!!');
				SET_ALERT_PROPERTY('ERROR_ALERT',TITLE,'ERROR');
				INSERT_MESSAGE := SHOW_ALERT('ERROR_ALERT');
				raise form_trigger_failure;
	END IF;	


		FORMS_DDL('INSERT INTO EMPLOYEES VALUES (:EMPLOYEES.EMP_ID, :EMPLOYEES.DEPARTMENT_DEPT_ID, :EMPLOYEES.EMP_NAME, :EMPLOYEES.EMP_NO, :EMPLOYEES.EMP_EMAIL)');

		COMMIT;
		SET_ALERT_PROPERTY('NOTE_ALERT',TITLE,'SAVE FORM');
		SET_ALERT_PROPERTY('NOTE_ALERT',ALERT_MESSAGE_TEXT,'The record has been inserted successfully');
		INSERT_MESSAGE:=SHOW_ALERT('NOTE_ALERT');

END;


But I dont why the message say it is empty when I try to show the department ID in an alert the right Id for the selected department name appear


DECLARE
	INSERT_MESSAGE NUMBER;

BEGIN
	
	
	IF (:EMPLOYEES.DEPARTMENT_DEPT_ID IS NULL OR :EMPLOYEES.EMP_NAME IS NULL OR :EMPLOYEES.EMP_NO IS NULL OR :EMPLOYEES.EMP_EMAIL IS NULL) THEN
				SET_ALERT_PROPERTY('ERROR_ALERT',ALERT_MESSAGE_TEXT,'You must enter all the fields !!!');
				SET_ALERT_PROPERTY('ERROR_ALERT',TITLE,'ERROR');
				INSERT_MESSAGE := SHOW_ALERT('ERROR_ALERT');
				raise form_trigger_failure;
	END IF;	

SET_ALERT_PROPERTY('ERROR_ALERT',ALERT_MESSAGE_TEXT,'You must enter all the fields !!!'||:EMPLOYEES.DEPARTMENT_DEPT_ID ||'');
		SET_ALERT_PROPERTY('ERROR_ALERT',TITLE,'ERROR');
		INSERT_MESSAGE := SHOW_ALERT('ERROR_ALERT');

		FORMS_DDL('INSERT INTO EMPLOYEES VALUES (:EMPLOYEES.EMP_ID, :EMPLOYEES.DEPARTMENT_DEPT_ID, :EMPLOYEES.EMP_NAME, :EMPLOYEES.EMP_NO, :EMPLOYEES.EMP_EMAIL)');

		COMMIT;
		SET_ALERT_PROPERTY('NOTE_ALERT',TITLE,'SAVE FORM');
		SET_ALERT_PROPERTY('NOTE_ALERT',ALERT_MESSAGE_TEXT,'The record has been inserted successfully');
		INSERT_MESSAGE:=SHOW_ALERT('NOTE_ALERT');

END;


Waiting your help Sad
lune
Re: Control Item help [message #239321 is a reply to message #239287] Tue, 22 May 2007 00:56 Go to previous messageGo to next message
kamran.it
Messages: 265
Registered: September 2005
Location: Karachi
Senior Member
If you have any button in this block then assign the button into new control_block (block which is not assoiated with database)

or

turn off the mouse navigate property of button.
Re: Control Item help [message #239342 is a reply to message #239321] Tue, 22 May 2007 01:30 Go to previous messageGo to next message
lune
Messages: 27
Registered: August 2006
Location: UAE
Junior Member

kamran.it

Thanks for your reply

I tried to turn off the mouse navigate property of button

but it didn't worked. the same error appeared again

Quote:

If you have any button in this block then assign the button into new control_block (block which is not assoiated with database)



Didn't understand how to do it

waiting your help

Thanks
lune
Re: Control Item help [message #239355 is a reply to message #239342] Tue, 22 May 2007 02:07 Go to previous messageGo to next message
kamran.it
Messages: 265
Registered: September 2005
Location: Karachi
Senior Member
if u have any button in database block then move it into new non database block


Re: Control Item help [message #239387 is a reply to message #239355] Tue, 22 May 2007 04:27 Go to previous message
lune
Messages: 27
Registered: August 2006
Location: UAE
Junior Member


kamran.it

I tried your solution but it didnt work

I will send you the form so you can have a look at it

Thanks
lune
Previous Topic: How to restrict entering alphabet into text box
Next Topic: Help in query Formating
Goto Forum:
  


Current Time: Wed Dec 07 03:16:40 CST 2016

Total time taken to generate the page: 0.16985 seconds