Trick to prevent people from writing or clicking in some form controls.

driver7408

Registered User.
Local time
Yesterday, 18:54
Joined
Feb 7, 2010
Messages
72
I figured this out today...after searching everywhere with no avail. I didn't like limit to list property because users could still click on the control. Also, due to the code I was running, clicking on caetain combobox text in my continuous form caused a repeat of the original IIF conditions in my code, causing the text in some of those comboboxes to actually disappear, due to the criteria of a given record (IIF code that based combobox records on checkbox criteria)

Solution:
No Code, no Macros... I simply placed an unlabeled textbox directly over the over the text portion of the combobox, set borders to transparent, bring to front, and locked it. User can still see the control, but cannot click on the text in the control unless I change the textbox properties (because this new textbox is in the way). Its like protecting the control with a little invisible window. I haven't tested it out on anything else, but I basically drug it over the top of a combobox and covered everything but the drop down arrow and it worked perfectly. This is gonna help me on several other forms I am using in my DB.

Hope this helps someone else if they find themselves in the same bind.
 
Why not simply set the Field's Locked property to True and the Enabled property to False :confused: This prevents your user from clicking or tabbing into the field.
 
Why not simply set the Field's Locked property to True and the Enabled property to False :confused: This prevents your user from clicking or tabbing into the field.


Because if it is locked or disabled then they cannot click on the combobox dropdown arrow and select records. I still needed them to be able to select records with the combobox. A locked combobox is pretty useless.
 
In that case simply Set the Locked property to True and leave the Enabled property as True. The user can still click in the Combo and see what's in the drop down put can not change the selection.
 
In that case simply Set the Locked property to True and leave the Enabled property as True. The user can still click in the Combo and see what's in the drop down put can not change the selection.

I am well aware of all the capabilities of the combo box properties, and I went through all of them while I was trying to find a solution. I need the user to be able to change the selection, just not click on the stagnant text next to the drop down arrow when it isn't being triggered. You would really have to see the subform, IIF statement and the query I am working with in order to understand what is going on here in my particular case, although it also applies to people who don't want their users clicking in the text portion of a usable (but) stagnant combo box and it suddenly looking editable whether it is or it isn't. I don't know why anyone would put a combo box in a form for any purpose other than record selection or adding in the first place, thus it makes no sense to use locked or enabled properties on a combo box to begin with.
 
There are any number of reasons that one might want to prevent a user making subsequent changes to a Combo once the selection has been committed.

Why not share the rest of your code with us so we can see exactly what it is that you are doing?
 
There are any number of reasons that one might want to prevent a user making subsequent changes to a Combo once the selection has been committed.

Why not share the rest of your code with us so we can see exactly what it is that you are doing?

This is a continuous (query-based) form with recordset combo boxes in each row. The text to the left/recordset of the box is a list of jobs. The combo box is the method of selecting the user or users who will do the job. The combo box criteria is based on 2 checkboxes to the right which decide 1 of 3 (1, 2 or 1+2)classes of names that will appear in the dropdown of the combo box when it is clicked upon, based upon the IIF statement that fires on the cbobox got focus event, that looks for which checkboxes are checked to return the source of names in the combo boxes. Still with me? Got focus and lost focus are the only way I got the code to work. (code I think found here after a long search) On got focus I have IIF, 1 else 2, and else 1+2, and under lost focus, it selects 1+2 (since the name was already selected in the combo box click during got focus.) After update and none of the form events worked; I select 1 and the 2's would disappear; vice versa. I have tried every logical form and combo box event I could try, and this seems to be all that works. The only issue is when you inadvertently click in only the text of a combo box after selecting either 1 or 2. The got focus causes all of the opposite checkbox IIF items to disappear, although they remain in the recordset. (code firing again since it is a got focus event as well) This is not pretty. I blocked the text stagnant portion of the combo box and now a person can click all over the form and not see names disappear. If he clicks on a dropdown arrow though, he can either re-select or keep the same name; either way, it looks much better and functions as I need it to. Maybe there is an easier way but I am on a bit of a deadline at this point. I'd be glad to send it if you would like to see it but it will have to be in a day or so when I get some time; anything that will help me learn more technique is a huge plus. I have a pretty major DB to build.
 

Users who are viewing this thread

Back
Top Bottom