Problem with code!

  • Thread starter Thread starter dee
  • Start date Start date
D

dee

Hi,
I have had some success with the help received here in making controls in my
forms locked if they have already been filled in and unlocked if they are
empty to allow the initial data entry.

I now have another problem. Two of the controls in question have default
values. One has one character and the other has 2. I have tried the code
below in variations, but only the box_no works, as it is simply empty of not.
The other two controls don't allow me to edit existing data, but also don't
allow me to enter the initial data!

Any suggestions would be greatly appreciated!
 
Forgot to post code:
Me.box_no.Locked = Not IsNull(Me.box_no)

If Len(Me.txt_ppt_no) = 9 Then
Me.txt_ppt_no.Locked = True
End If
If Len(Me.txt_study_no & vbNullString) < 3 Then
Me.txt_study_no.Locked = False
End If
 
dee said:
Forgot to post code:
Me.box_no.Locked = Not IsNull(Me.box_no)

If Len(Me.txt_ppt_no) = 9 Then
Me.txt_ppt_no.Locked = True
End If
If Len(Me.txt_study_no & vbNullString) < 3 Then
Me.txt_study_no.Locked = False
End If


I think you can get away with checking if they are the same
as the default value.

If Not (IsNull(Me.txt_ppt_no) Or Me.txt_ppt_no = _
Eval(Me.txt_ppt_no.DefaultValue)) Then
Me.txt_ppt_no.Locked = True
End If
If Not (IsNull(Me.txt_study_no) Or Me.txt_study_no = _
Eval(Me.txt_study_no.DefaultValue)) Then
Me.txt_study_no.Locked = False
End If
 
Hi Marshall,

Thanks so much. I fiddled around with the code and it's working.

I appreciate your help and sharing your knowledge!
 
Back
Top