Browse / Form template behaviour

Hi.
I am using the standard browse / form template to write records. After the insert action, a form appears. Several entry fields are filled with default values. The user presses Esc and the question appears: Do you want to save the changes?
I would like to omit this question and cancel the form immediately because the user has not entered any values.
The question is only needed when the user changes at least one entry field (using the keyboard).
Regards,
Adam

How are you populating the default values?

In source code in ThisWindow.Init

SELF.Open(QuickWindow) ! Open window
! [Priority 8001]
LOC:Name=‘my default name’
LOC:Date=today()

You want to put the default settings in the PrimeFields method of ThisWindow.
This will allow the built-in logic that captures the value of the fields of your table to work with your default values. Where you are doing it is too late. The “snapshot” of the table record buffer has already happened.

4 Likes

As Rick said, the best option is to use the PrimeFields method.

If, for some reason, you need to change default values later, this worked for me:

  IF somecondition
    ACCESS:sometable.RestoreBuffer(SELF.Saved,0) !Release original buffer
    SELF.Saved = ACCESS:sometable.SaveBuffer()   !Replace with current
  END

Must be in one of the WindowManager derived methods.

1 Like

Concerning suppressing the message window, on the update window Actions, look for the “On Aborted Add/Change” and select the desired action.

Good to know, but if he does that the user would not get the warning to save the changes the user made. The OP appeared to not want his default values to trigger the save message.

  1. Change “On Aborted Add/Change” to “Cancel without confirming"
  2. You can use the free template “Control Users ability to Exit”
  3. I use embed code before (priority 2501) TakeAccepted to check particular fields like
    CASE FIELD()
    OF ?Field1
    OF ?Field2
    .
    to block exit if there is something entered by the user or allow after confirm message created by you.
    You can use post EVENT:Accepted ?Ok or ?Cancel.

The easiest way is to save buffer after setting default values in thiswindow.init()

SELF.Saved = ACCESS:sometable.SaveBuffer()

All works perfect.
:slight_smile:

1 Like