Lock Controls

Hi
I am trying to lock fields based on a selection from a drop down box.  I created a table, where I tagged the fields I want locked based on the selection. The code locks the fields, it just won't unlock the fields.

This portion does not work.  Is this the wrong syntax?
If mycheck3 Like "" Then
   Me.AllowEdits = True

Any thoughts are appreciated.  Thanks
Dim mycheck3, MyDB1 As Database, MYDBR1 As Recordset
Set MyDB1 = CurrentDb
Set MyDB1 = DBEngine.Workspaces(0).Databases(0)
Set MYDBR1 = MyDB1.OpenRecordset("test_field_locks", DB_OPEN_DYNASET)
    mycheck3 = MYDBR1("Adj_Lock").Value
        If Me.Status = "Submitted" Then
            If mycheck3 Like "LS" Then
                Me.AllowEdits = False
            If mycheck3 Like "" Then
                Me.AllowEdits = True
                Me.Refresh
                
            End If
         End If
    End If
MYDBR1.Close
MyDB1.Close

Open in new window

mato01Asked:
Who is Participating?
 
mato01Connect With a Mentor Author Commented:
The information is business sensitive so I can't send you the file.

I've been calling the code in the after update.  I will try the "open event".
0
 
Rey Obrero (Capricorn1)Commented:

If mycheck3 = "" Then
   Me.AllowEdits = True
0
 
mato01Author Commented:
Changed to
If mycheck3 = " " Then
    Me.AllowEdits = True

Did not work.  All the fields remain locked.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Rey Obrero (Capricorn1)Commented:
my code is

 If mycheck3 = "" Then   ' < no space

yours

If mycheck3 = " " Then
0
 
mato01Author Commented:
Did not work

If mycheck3 = "" Then
0
 
Rey Obrero (Capricorn1)Commented:
try this

If isNull(mycheck3) or len(mycheck3 & "")=0 then

    Me.AllowEdits = True
0
 
mato01Author Commented:
No that did not work. It seems like it once its locked it will not unlock.
0
 
Rey Obrero (Capricorn1)Commented:
can you upload your db?

check Attach File below..
0
 
Rey Obrero (Capricorn1)Commented:
btw, where are you calling the codes?

you should call the codes in the *open event* of the form.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.