![]() |
Retaining focus on a textbox / listbox item pair after validation = false.
Hi Everybody.
I have a wee problem that has evaded my best efforts over the past couple of days and I hope one of you out there can shine some light for me. The problem centres on two form controls. Essentially there is a text box and a list box. For each entry of the list the user must enter a conversion rate into the text box. The user clicks a list item then enters a value into the text box. The user then either clicks another list item or decides to do something else. My problem begins with validation of the text box entry. I do not wish to use a textbox_change event, but rather wait until the user clicks another list item or other control, before I trigger the validation. If validation is true, no problems. However, if validation is false, eg. the user entered a word string, no matter how I code it, using textbox_Exit (with Cancel = true, or enable = false then true, etc) or other text box event, or a _listbox event, I am not able to figure out how to both keep focus on the incorrect text box entry and force the list box to stay on the offending list item. My best to date has been to keep focus on the textbox offending entry, but the listbox moves to the new user selection. If anybody can shed some light on how I might do this without having to include a dedicated 'OK' button for each new user entry, I would be most grateful Ciao for now. chatterbox |
Retaining focus on a textbox / listbox item pair after validation = false.
It looks to me like you should add an "Update" button for the user to click
after they have selected an item in the list, then entered the conversion rate in the text box. This could be the default button. When the user presses the return key, validation would be performed, and focus returned to the text box for editing, if necessary. Otherwise, if the user simply selects another list item, Excel doesn't know whether to apply the conversion rate to the previously selected list item. Maybe nothing should be done, because the user simply selected the wrong item in the list box. Good form design usually means that the Cancel button also exits from the form, just like the OK button, but any changes are cancelled (undone). If the user selects an item in the list box, enters a conversion rate in the text box, and then decides to hit the Cancel button, what should happen? Should all previous changes/entries be undone? -- Regards, Bill |
Retaining focus on a textbox / listbox item pair after validation = false.
Bill Renaud wrote: It looks to me like you should add an "Update" button for the user to click after they have selected an item in the list, then entered the conversion rate in the text box. This could be the default button. When the user presses the return key, validation would be performed, and focus returned to the text box for editing, if necessary. Otherwise, if the user simply selects another list item, Excel doesn't know whether to apply the conversion rate to the previously selected list item. Maybe nothing should be done, because the user simply selected the wrong item in the list box. Good form design usually means that the Cancel button also exits from the form, just like the OK button, but any changes are cancelled (undone). If the user selects an item in the list box, enters a conversion rate in the text box, and then decides to hit the Cancel button, what should happen? Should all previous changes/entries be undone? -- Regards, Bill Thanks Bill for the advice. I started down the road you advised, but then had an all too rare flash of inspiration. I used the textbox_Exit event to kick off the validation. If it validated good, no action was taken. If it validated false it locked the list box, passed a message to the user and set focus back on the text box. I have included OK and Cancel command buttons as you suggest. Thanks again. chatterbox |
All times are GMT +1. The time now is 02:25 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com