Avoid closing a form

xavigepexavigepe Member Posts: 185
I have a card form in which some fields are compulsory, so I don't want to let the user close this form if he or she has not informed these fields. How can I do it?.

Thanks,

Answers

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Write your check in the OnQueryCloseForm-trigger:
    OnQueryCloseForm() : Boolean
    IF "Phone No." = '' THEN 
      ERROR('Please fill in the Phone No.');
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • xavigepexavigepe Member Posts: 185
    OK. That's fine.

    If I also wanted to avoid the user not only closing the form but moving to another record in the form?. How could I do it?.

    Thanks so much,
  • amunozsuamunozsu Member Posts: 30
    Hi,

    Try this in the OnNextRecord Trigger:
    IF Condition THEN
       BEGIN
         IF (NOT CONFIRM("Continue anyway?, TRUE)) THEN
            BEGIN
                CurrForm.WrongField.ACTIVATE
                EXIT(Steps);
            END
         ELSE
            BEGIN
              NEXT(Steps);
              EXIT(Steps);
            END;
       END
    ELSE
       BEGIN
         NEXT(Steps);
         EXIT(Steps);
       END;
    

    Un saludo,

    -- Alejandro --
  • xavigepexavigepe Member Posts: 185
    OK funciona. Muchas gracias :D
  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    We discusseed it a number of times. Shortly: set form to DelayedInsert. Put code into OnInsert. There are more sophisticated solutions based on this idea. Search for it.
Sign In or Register to comment.