lock checkbox on open form

megatronixs

Registered User.
Local time
Today, 03:39
Joined
Aug 17, 2012
Messages
719
Hi all,

I'm trying to lock a checkbox when the forms open and depending if one has role as admin, it should unlock it.
When I add the below code in the on open form I get error:
Code:
Me.lock_case_admin.Locked = True
Me.lock_case_admin.BackColor = 12632256

This is the part that should onlock if it is admin:
Code:
Me.lock_case_admin.Locked = False
Me.lock_case_admin.BackColor = 16777215

Maybe it is me, or the checkbox is giving the error that causes the dialogbox to open to to choose the ID nr.

Greetings.
 
Try
Code:
Me.lock_case_admin.Enabled = True / False
rather than locked and trying to change the backcolor.
 
Could you mention error message you get?
 
Hi TJPoorman, I used your tip on the enable true/false and works great.
I managed to get this code working:

Code:
If varUserLock = "Admin" Then
Me.[lock_case_admin].Enabled = True
Else
Me.[lock_case_admin].Enabled = False
End If

Now I try to also via VBA to check the checkbox when a user selects a status from a dropdownbox "Marked as Frozen"

Code:
If Me.[Case_Status] = "Marked as Frozen" Then
Me.[lock_case_admin] = True
End If

This does not want to work, no matter if I change it to 0, Yes.

Any idea where this could go wrong?

Greetings.
 
Hi khurram7x,

Actually it is not an error message box, just the evil dialog box that ask you for a value in one of the fields. I cancel it out and then the code stops and get the yellow marker on some code line that has nothing to do what goes wrong.

Greetings.
 
Hi all,

I got it solved. After retyping it in again, I saw the silly typo :-)
Now it works great.

Greetings.
 

Users who are viewing this thread

Back
Top Bottom