Backspaces and Form Focus

Backspaces and Form Focus

I have two questions:

  1. When using the Backspace key to delete content in a text box, the control is passed to the preceding text box once all data is erased. Can this be disabled?
  2. When calling one form from another, the form to be loaded doesn’t receive the focus; thus the user has to click on the form first before using the form. How do I correct this?

To prevent loss of focus when pressing Backspace once all data has been erased, put the following code into the KeyPress Event of the textbox:

 LPARAMETERS nKeyCode, nShiftAltCtrl*-- If textbox value is empty and the *-- backspace key was pressed, ignore*-- the keyIF EMPTY(this.Value) AND nKeyCode = 127   NODEFAULTENDIF

Regarding the focus issue, you may want to call the SetFocus() method of the called form to make sure that it receives focus.


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist