Home » Developer & Programmer » Forms » Compare textfield value
Compare textfield value [message #169988] Mon, 01 May 2006 09:21 Go to next message
juicyapple
Messages: 92
Registered: October 2005
Member
I have created a form, frmRec and datablock, dbRec with 3 textfields (item, code and date) and number of records displayed = 10.

If user insert same item and code more than one time, date value must be same for these two item, if not, error message will be prompted out.

Please give some idea on how the validation/ control can be done?
Thanks.
Re: Compare textfield value [message #170034 is a reply to message #169988] Mon, 01 May 2006 15:52 Go to previous message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
One solution might be something like this: after you insert values into the record, POST (not COMMIT, but POST) it. Write the WHEN-VALIDATE-ITEM on the date item, such as:

SELECT MAX(t.date_item)
INTO :global.date_item
FROM your_table t
WHERE t.item = :item
AND t.code = :code;

IF :global.date_item <> :date_item
THEN
MESSAGE('Date value should be ' || :global.date_item);
RAISE form_trigger_failure;
END IF;

Now, the global variable should perhaps be replaced with a local one; MAX function is here just to avoid the NO-DATA-FOUND error - you'd better deal with it using an exception handler. But, I *hope* that the general idea could work.

[EDIT] About the :global.date_item: as global variables are of a CHARACTER datatype, I *think* that IF, written the way it is, wouldn't work properly. Therefore, either substitute global variable with a local (DATE) one, or use TO_DATE function with the global variable.

[Updated on: Mon, 01 May 2006 15:54]

Report message to a moderator

Previous Topic: "update record" does not updates. why?
Next Topic: How to select the values from one list box to other
Goto Forum:
  


Current Time: Fri Sep 20 09:29:41 CDT 2024