Allow edits to one field while AllowEdits is false

J

jamesNew

Hello,

I've inherited an Access project and need to make some updates. I don't
know where to start or even how to word this question correctly.

When the form opens, it does a check on the username and assigns an
admin level.
Based on this level, different toolbars are shown/hidden and the forms
DataEntry bit is on/off. Now, I need to change one of the admin levels
so that the toolbars are still hidden (for that level), the Form will
not allow any data entry, *except* for a text field named "AttendNotes"

Does this make sense? Is this possible?

Thanks,
James
 
R

Rick Brandt

Hello,

I've inherited an Access project and need to make some updates. I
don't know where to start or even how to word this question correctly.

When the form opens, it does a check on the username and assigns an
admin level.
Based on this level, different toolbars are shown/hidden and the forms
DataEntry bit is on/off. Now, I need to change one of the admin levels
so that the toolbars are still hidden (for that level), the Form will
not allow any data entry, *except* for a text field named
"AttendNotes"

Does this make sense? Is this possible?

Thanks,
James

You can't use AllowEdits = False then. Instead you can loop through the
controls on the form and Lock/Unlock them. This allows you to leave some of
them unlocked when you do the locking loop. I usually give all of the
controls I want to toggle a common TAG property then...

Dim cnt as Control
For Each cnt in Me
if cnt.Tag = "SomeString" Then cnt.Locked = True
Next cnt
 
J

jamesNew

Hi Rick,

Thanks for your response.

I set the tag fo the AttendNotes field to "unlock" and put this code
in:

If UserCheck >= 3 Then
Dim cnt As Control
For Each cnt In Me
If cnt.Tag <> "Unlock" Then
cnt.Locked = False
Else
cnt.Locked = True
End If
Next cnt
End If

when running it I get run-time error '438', Object doesn't support this
property.... with a break at the line ' cnt.Locked = False'

Thanks,
James
 
R

Rick Brandt

Hi Rick,

Thanks for your response.

I set the tag fo the AttendNotes field to "unlock" and put this code
in:

If UserCheck >= 3 Then
Dim cnt As Control
For Each cnt In Me
If cnt.Tag <> "Unlock" Then
cnt.Locked = False
Else
cnt.Locked = True
End If
Next cnt
End If

when running it I get run-time error '438', Object doesn't support
this property.... with a break at the line ' cnt.Locked = False'

Thanks,
James

You need to check for Tag = something rather than <> something otherwise it is
going to try to set the Locked property for EVERY control with a blank Tag
property and some of your controls don't have a Locked property (labels for
example). That causes the error.
 
F

Fred Morrison

Hi Rick,

Thanks for your response.

I set the tag fo the AttendNotes field to "unlock" and put this code
in:

If UserCheck >= 3 Then
Dim cnt As Control
For Each cnt In Me
If cnt.Tag <> "Unlock" Then
cnt.Locked = False
Else
cnt.Locked = True
End If
Next cnt
End If

when running it I get run-time error '438', Object doesn't support this
property.... with a break at the line ' cnt.Locked = False'

Thanks,
James

Also, shouldn't the line that current reads:

For Each cnt In Me
be changed to:
For Each cnt In Me.Controls

Any time you use For Each, you need to specifiy which Collection you are
trying to iterate through. In this case, it sounds like you want to iterate
through the Controls collection on the current form (Me in this case).
 
R

Rick Brandt

Fred said:
Also, shouldn't the line that current reads:

For Each cnt In Me
be changed to:
For Each cnt In Me.Controls

Any time you use For Each, you need to specifiy which Collection you
are trying to iterate through. In this case, it sounds like you want
to iterate through the Controls collection on the current form (Me in
this case).

It's not a bad idea for clarity's sake, but the controls collection is the
default collection for a Form or Report so it doesn't need to be explicitly
entered.
 
Top