Home » Developer & Programmer » Forms » do you want to save changes
do you want to save changes [message #134228] Wed, 24 August 2005 00:46 Go to next message
VSPB
Messages: 27
Registered: August 2005
Junior Member
i've a master form. on its exit button i've written
exit_form(ask_commit);
so that it will ask before exiting. but it gives the message even if no changes are made. and if i click yes it also saves a blank record...
Re: do you want to save changes [message #134267 is a reply to message #134228] Wed, 24 August 2005 02:30 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Then your record is not truly 'blank', it has at least one field which has had a hard NULL put into it.

What triggers do you have in your form? Are you autopopulating some of your fields with NULL or space? Are you setting a field to itself?

David
Re: do you want to save changes [message #134519 is a reply to message #134267] Thu, 25 August 2005 07:01 Go to previous messageGo to next message
VSPB
Messages: 27
Registered: August 2005
Junior Member
Well yes i pass some null values on When-new-form-instance. but i need to give them...
Here is my code

WHEN-NEW-FORM-INSTANCE-TRIGGER

:DI_EMPNAME := :PARAMETER.P_EMPNAME;

begin
if :PARAMETER.P_ITEMID is not null then
set_block_property('ITEM_M',default_where,'ITEM_ID='||:PARAMETER.P_ITEMID);
go_block('ITEM_M');
execute_query;
end if;
--Code for enabling/disabling the month of usage text box on the basis of seasonal item
IF :IS_SEASONAL_ITEM = 'N' or :IS_SEASONAL_ITEM = '' THEN
SET_ITEM_PROPERTY('month_of_usage',enabled,property_false);
:month_of_usage := '';
else
SET_ITEM_PROPERTY('month_of_usage',enabled,property_true);
SET_ITEM_PROPERTY('month_of_usage',update_allowed,property_true);
END IF;
--Code for enabling/disabling the month of usage text box on the basis of seasonal item end

--Code for enabling/disabling the Lead Value text box on the basis od Reorder Type
IF :Reorder_Type = '' or :Reorder_Type is null THEN
SET_ITEM_PROPERTY('Lead_Value',enabled,property_false);
:Lead_Value := '';
else
SET_ITEM_PROPERTY('Lead_Value',enabled,property_true);
SET_ITEM_PROPERTY('Lead_Value',update_allowed,property_true);
END IF;
--Code for enabling/disabling the Lead Value text box on the basis od Reorder Type end
end;

DECLARE
group_id RecordGroup;
List_id Item := Find_Item('item_location_d.ITEM_LOCATION_ID');
status NUMBER;
BEGIN
group_id := Create_Group_From_Query('RACK_NAME','SELECT RACK_NO,to_char(ITEM_LOCATION_ID) FROM ITEM_LOCATION_M order by RACK_NO');
status := Populate_Group(group_id);
Populate_List(List_id,group_id);
END;
Re: do you want to save changes [message #134631 is a reply to message #134519] Thu, 25 August 2005 17:49 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay, here's your code back at you
-- WHEN-NEW-FORM-INSTANCE-TRIGGER

declare
begin
   :DI_EMPNAME := :PARAMETER.P_EMPNAME;

   begin
      if :PARAMETER.P_ITEMID is not null then
         set_block_property ('ITEM_M', default_where,
                             'ITEM_ID=' || :PARAMETER.P_ITEMID);
         go_block ('ITEM_M');
         execute_query;
      end if;

--Code for enabling/disabling the month of usage text box on the basis of seasonal item
      IF    :IS_SEASONAL_ITEM = 'N'
         or :IS_SEASONAL_ITEM = '' THEN
         SET_ITEM_PROPERTY ('month_of_usage', enabled, property_false);
         :month_of_usage := '';
      else
         SET_ITEM_PROPERTY ('month_of_usage', enabled, property_true);
         SET_ITEM_PROPERTY ('month_of_usage', update_allowed, property_true);
      END IF;

--Code for enabling/disabling the month of usage text box on the basis of seasonal item end

      --Code for enabling/disabling the Lead Value text box on the basis od Reorder Type
      IF    :Reorder_Type = ''
         or :Reorder_Type is null THEN
         SET_ITEM_PROPERTY ('Lead_Value', enabled, property_false);
         :Lead_Value := '';
      else
         SET_ITEM_PROPERTY ('Lead_Value', enabled, property_true);
         SET_ITEM_PROPERTY ('Lead_Value', update_allowed, property_true);
      END IF;
--Code for enabling/disabling the Lead Value text box on the basis od Reorder Type end
   end;

   DECLARE
      group_id   RecordGroup;
      List_id    Item        := Find_Item ('item_location_d.ITEM_LOCATION_ID');
      status     NUMBER;
   BEGIN
      group_id :=
         Create_Group_From_Query
            ('RACK_NAME',
             'SELECT RACK_NO,to_char(ITEM_LOCATION_ID) FROM ITEM_LOCATION_M order by RACK_NO');
      status := Populate_Group (group_id);
      Populate_List (List_id, group_id);
   END;
end;
I recommend that you ALWAYS put the block identifier in your code. Don't just have ':DI_EMPNAME' but use ':BLK.DI_EMPNAME'.

Why are you setting the 'Lead_Value' to null string? I suggest you test for it being 'not null' before doing the assignment.
if :blk.Lead_Value is not null then
  :blk.Lead_Value := NULL;
end if;


David
Re: do you want to save changes [message #134689 is a reply to message #134631] Fri, 26 August 2005 04:01 Go to previous messageGo to next message
VSPB
Messages: 27
Registered: August 2005
Junior Member
hi david,
thanks for the suggestion of using block identifier... i will keep in mind from now on...
i tried assigning NULL and checking it before assignment but it didnt work. it still gives the message on the click of exit button even if no changes are made...
Please help...
Re: do you want to save changes [message #134890 is a reply to message #134689] Sun, 28 August 2005 17:42 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Can you elaborate on "checking it before assignment but it didnt work". You also say "it still gives the message on the click of exit button even if no changes are made...". There is one thing of which I am certain, Forms does NOT ask for a Save if there are no changes. It just means that we can't FIND what it is that we have changed!

Put a "message('trigger name: status='||:system.record_status); pause;" statement into as many of your triggers as is necessary, and in as many places as possible. Then just 'follow the boring messages'.

David
Re: do you want to save changes [message #134906 is a reply to message #134890] Sun, 28 August 2005 22:18 Go to previous messageGo to next message
swchen
Messages: 15
Registered: July 2005
Location: malaysia
Junior Member
Hello, Mr.David i also have facing the same problem now. The message 'Do you want save change you make' will keeping prompt out even i din make any change at record. Actually, what cause making the message keeping prompt out?? Sir, you have any idea or advise to us to avoid this happen?? Thanks,have nice day.
Re: do you want to save changes [message #134909 is a reply to message #134906] Sun, 28 August 2005 23:36 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
As I said in my previous post - "Forms does NOT ask for a Save if there are no changes".

Put a
message('trigger name: status 1 ='||:system.record_status); pause;"
statement into as many of your triggers as is necessary, and in as many places as possible. Just remember to change the 'number' so that each message is unique.

Compile and run your form and follow the flow of your form via the messages that are displayed.

David

[Updated on: Sun, 28 August 2005 23:37]

Report message to a moderator

Re: do you want to save changes [message #134917 is a reply to message #134909] Mon, 29 August 2005 00:32 Go to previous messageGo to next message
VSPB
Messages: 27
Registered: August 2005
Junior Member
hello Mr. David,
i tried showing the message
message('trigger name: status 1 ='||:system.record_status); pause;

and three places i got status = CHANGED

1ST - POST QUERY OF THE MASTER BLOCK...

IF :IS_SEASONAL_ITEM = 'N' or :IS_SEASONAL_ITEM = '' THEN
SET_ITEM_PROPERTY('month_of_usage',enabled,property_false);
:month_of_usage := '';
else
SET_ITEM_PROPERTY('month_of_usage',enabled,property_true);
SET_ITEM_PROPERTY('month_of_usage',update_allowed,property_true);
END IF;
message('trigger name: status 6 ='||:system.record_status); pause;

2ND & 3RD - WHEN NEW FORM INSTANCE...
--Code for enabling/disabling the month of usage text box on the basis of seasonal item
IF :IS_SEASONAL_ITEM = 'N' or :IS_SEASONAL_ITEM = '' THEN
SET_ITEM_PROPERTY('month_of_usage',enabled,property_false);
:month_of_usage := '';
else
SET_ITEM_PROPERTY('month_of_usage',enabled,property_true);
SET_ITEM_PROPERTY('month_of_usage',update_allowed,property_true);
END IF;
--Code for enabling/disabling the month of usage text box on the basis of seasonal item end

--Code for enabling/disabling the Lead Value text box on the basis od Reorder Type
IF :Reorder_Type = '' or :Reorder_Type is null THEN
SET_ITEM_PROPERTY('Lead_Value',enabled,property_false);
:Lead_Value := '';
else
SET_ITEM_PROPERTY('Lead_Value',enabled,property_true);
SET_ITEM_PROPERTY('Lead_Value',update_allowed,property_true);
END IF;
--Code for enabling/disabling the Lead Value text box on the basis od Reorder Type end
message('trigger name: status 2 ='||:system.record_status); pause;

DECLARE
group_id RecordGroup;
List_id Item := Find_Item('item_location_d.ITEM_LOCATION_ID');
status NUMBER;
BEGIN
group_id := Create_Group_From_Query('RACK_NAME','SELECT RACK_NO,to_char(ITEM_LOCATION_ID) FROM ITEM_LOCATION_M order by RACK_NO');
status := Populate_Group(group_id);
Populate_List(List_id,group_id);
END;
message('trigger name: status 3 ='||:system.record_status); pause;

but i cannot change the above code... i need to assign those null values to LEAD_VALUE and MONTH_OF_USAGE... and populate the 'ITEM_LOCATION_D.ITEM_LOCATION_ID' list item... but this code is making changes in the form... is there any other way i can do it. it will be very helpful... thank you...
Re: do you want to save changes [message #134920 is a reply to message #134917] Mon, 29 August 2005 00:56 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
In a previous post to this thread I said
Quote:

Why are you setting the 'Lead_Value' to null string? I suggest you test for it being 'not null' before doing the assignment.
if :blk.Lead_Value is not null then
  :blk.Lead_Value := NULL;
end if;


I ask again, why are you setting a data base item to NULL in the When-New-Form-Instance?

By the way, please put the block in your item names.

But first, let's just get the Post-Query correct. Why do you want to clear the ':month_of_usage' field? Your code
IF :IS_SEASONAL_ITEM = 'N' or :IS_SEASONAL_ITEM = '' THEN
SET_ITEM_PROPERTY('month_of_usage',enabled,property_false);
:month_of_usage := '';
tells me that 'if the retrieved record has an IS_SEASONAL_ITEM set to 'N' or NULL the value in the month_of_usage field is to be destroyed'. I think what you really mean is 'I don't want to see the value of month_of_usage on this line'. If this is the case then you need to have a 'display' field on the canvas and not the 'real' data base field. Then you populate that display field when necessary and in its When-Validate-Item trigger if the value in the 'display' field is different to the 'real' field then you populate the 'real' field.

David
Re: do you want to save changes [message #134925 is a reply to message #134920] Mon, 29 August 2005 01:27 Go to previous messageGo to next message
VSPB
Messages: 27
Registered: August 2005
Junior Member
I am setting those items to NULL in the When-New-Form-Instance because when the form opens for a new entry lead_value should be null till any reorder_value is selected and month_of_usage should be null till seasonal_item is not checked.

if :blk.Lead_Value is not null then
:blk.Lead_Value := NULL;
end if;


i tried this but it didnt work...
Re: do you want to save changes [message #134927 is a reply to message #134925] Mon, 29 August 2005 01:33 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
What happens if you don't have these assignments statements in your code? Please comment out the IF tests and assignments to NULL and retest your form.

David
Re: do you want to save changes [message #134974 is a reply to message #134927] Mon, 29 August 2005 04:59 Go to previous messageGo to next message
VSPB
Messages: 27
Registered: August 2005
Junior Member
then it works properly... but i want to give those assignments...
Re: do you want to save changes [message #135084 is a reply to message #134974] Mon, 29 August 2005 18:09 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
You say
Quote:

am setting those items to NULL in the When-New-Form-Instance because when the form opens for a new entry lead_value should be null till any reorder_value is selected

WNFI is for FORM things, you say 'for a new entry', you should think more along the lines of When-New-Record-Instance not WNFI.

Okay, these 'assignments' are really validation tests. I suggest that you put the logic into When-Validate-Item triggers on the various fields. For example, on month_of_usage and seasonal_item have a WVI that tests to make sure that the pair of fields are compatiable. If they aren't then tell the user they are wrong and do a 'raise form_trigger_failure'.

David

[Updated on: Mon, 29 August 2005 18:09]

Report message to a moderator

Previous Topic: ...Active X Control
Next Topic: lov control popup at runtime
Goto Forum:
  


Current Time: Thu Sep 19 23:31:03 CDT 2024