Form security

GJT

Registered User.
Local time
Today, 20:35
Joined
Nov 5, 2002
Messages
116
I am using a switchboard similar to that used in the Northwind sample database.

What I need to do is restrict access to certain buttons on the switchboard. To do this I have a table that lists all switchboard captions, thus the form structure is built 'on-the-fly'. The table also specifies the user access rights by way of an integer value 1,2 or 0 (1 admin / 2 - user / 0 is all access).

When the form is loaded, the code checks the access value for the button and disables/enables accordingly. However, Access reports an error : 2164 - "You can't disable a control while it has the focus" - how can I get around this problem?
 
Set the focus to another object before you try to disable the button in your routine.

Me.AnotherObject.SetFocus

HTH
 
If I am using 3 buttons and the first button is to be disabled - am I going to have write a routine to force focus to the second button? And in those instances where the the second button is to be disabled force focus to the previous enabled button???.... there has to be a neater way....surely....??????
 
As you have discovered, you can not disable an object [button] that has the focus. You have to set the focus to another object before your can disable the object.

I always have a text box named tbHidden on my forms. I use that text box to set the tab order to 0 and I use the tbHidden text box as my "focus" source when needed. It also gives a cleaner appearance when I do this so that no button have the focus after a routine is run.

Here is a link to one of my samples that is using the tbHidden text box. I have set the size of the tbHidden text box to a minuscule of 0.0097" x 0.0097"

http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=54309

HTH
 
Thanks a bundle.... does exactly what I want!
 

Users who are viewing this thread

Back
Top Bottom