This discussion is archived
5 Replies Latest reply: Dec 13, 2012 1:32 PM by Andreas Weiden RSS

navigating away from not null fields

newbi_egy Explorer
Currently Being Moderated
hi all ,
db and dev"10g rel2" , xp sp3

--
i have to blocks ,
1- "patients" : for inserting patients data by a button
2- "inserted_patients" : for showing the patients' data inserted , to enable user to choose a patient's record to update
or delete .
3- a button for inserting the data of the patients block .

4- the patients block has these not null fields "pat_id , pat_name and test" .

--
when button pressed

go_block('patients') ;

if :system.block_status = 'CHANGED'
     THEN
     commit ;
     clear_block ;
     go_block('inserted_patients') ;
     execute_query ;
end if ;
:patients.test_date := sysdate ;

this process is going well , but the problem is that there is an "update button" , the user should choose a record of
the "inserted_patients" block to update . and i can not choose any record if the not null fields of the "patients"block are null .

how can i get rid of this problem ?


i think of setting the required property of the "patients" block to"no" , and validate the null fields only when the "insert" button pressed , but how ? -- tell me how if this solution is good or tell me another one .

thanks in advance
  • 1. Re: navigating away from not null fields
    Andreas Weiden Guru
    Currently Being Moderated
    :patients.test_date := sysdate ;
    Why this? This causes the record in the patients-block to be "changed" and therefore the Require-fields are enforced.
  • 2. Re: navigating away from not null fields
    newbi_egy Explorer
    Currently Being Moderated
    Why this? This causes the record in the patients-block to be "changed"
    because i do not want the user to put the sysdate manually , i want the application do it for him ,
    and
    suppose that the date field is empty , the user could fill the "pat_id" field with a number , then navigate to "pat_name", then press the "insert" button , so the block is "changed" as well . "the same situation "


    and i think that the required fields are enforced even if the block is empty .

    - could you give me a code as an example for inserting patients data by clicking the button , considering showing a message if there are null fields when the user presses the button ?


    thanks
  • 3. Re: navigating away from not null fields
    Andreas Weiden Guru
    Currently Being Moderated
    because i do not want the user to put the sysdate manually , i want the application do it for him
    then you should use the way which is intened for defaultirn fields. Put either $$DBDATE$$ in the default-value-property, or create a WHEN-CREATE-REOCRD-trigger and assign the date there.
    and i think that the required fields are enforced even if the block is empty
    No, as long as you do not start editing a record its treated as new and no validations will occur.
    could you give me a code as an example for inserting patients data by clicking the button
    I thought i already suggested some possible ways in an earlier post?
  • 4. Re: navigating away from not null fields
    newbi_egy Explorer
    Currently Being Moderated
    Put either $$DBDATE$$ in the default-value-property .
    thanks a lot for this new information , but i think you've meant the "initial value" property ? , because i searched for the
    "default value" property , and i find nothing .
    as long as you do not start editing a record its treated as new and no validations will occur.
    i've tried this , and sure you are right , but the problem still exist , because i've said before , the user can put a value
    in the "pat_name" field for example , then he wants to navigate to the "inserted_patients" block , so , the "field must be entered is shown" , and he can not navigate .


    so , i've two problems now ,
    1- i want a message to be shown to the user , if he presses the "insert" button , and there are not null fields without a value , then the cursor goes to the first not null field which needs a value .

    2- i want the user to navigate to the "inserted_patients" any time he wants .

    i really appreciate your help andreas .

    thanks again

    Edited by: semsem on Dec 12, 2012 3:30 PM
  • 5. Re: navigating away from not null fields
    Andreas Weiden Guru
    Currently Being Moderated
    Well, if you want to stick with your logic, make the fields nullable and do a check on the when-button-pressed.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points