Link to home
Start Free TrialLog in
Avatar of mato01
mato01Flag for United States of America

asked on

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

Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image


If mycheck3 = "" Then
   Me.AllowEdits = True
Avatar of mato01

ASKER

Changed to
If mycheck3 = " " Then
    Me.AllowEdits = True

Did not work.  All the fields remain locked.
my code is

 If mycheck3 = "" Then   ' < no space

yours

If mycheck3 = " " Then
Avatar of mato01

ASKER

Did not work

If mycheck3 = "" Then
try this

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

    Me.AllowEdits = True
Avatar of mato01

ASKER

No that did not work. It seems like it once its locked it will not unlock.
can you upload your db?

check Attach File below..
btw, where are you calling the codes?

you should call the codes in the *open event* of the form.
ASKER CERTIFIED SOLUTION
Avatar of mato01
mato01
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial