Running same code on many fields...

P

paradise95969

I'm using a field in the record to lock or unlock another field:

Private Sub Special_Concerns_GotFocus()
If Me.CheckEdit.Value = True Then 'true means edit is ok
Me.ActiveControl.Locked = False
Else: Me.ActiveControl.Locked = True
End If
End Sub

As you can see this is on GotFocus(). I would like to apply this to many
fields. Is there a better way to do it verses adding it to the event property
for each field separately? I'm assuming there is- but I have not figured that
out and would like to improve my design where possible.

Thanks
paradise95959
 
B

Bob Quintal

paradise95969 said:
I'm using a field in the record to lock or unlock another field:

Private Sub Special_Concerns_GotFocus()
If Me.CheckEdit.Value = True Then 'true means edit is ok
Me.ActiveControl.Locked = False
Else: Me.ActiveControl.Locked = True
End If
End Sub

As you can see this is on GotFocus(). I would like to apply this
to many fields. Is there a better way to do it verses adding it to
the event property for each field separately? I'm assuming there
is- but I have not figured that out and would like to improve my
design where possible.

Thanks
paradise95959
I usually use the form's current event to lock or unlock a set of
fields using a single line per field

me.field1.locked = NOT me.Checkedit Value
me.field2.locked = NOT me.Checkedit Value
me.field3.locked = me.Check2 Value

etc.

If I need to update that status at some point in the edit, I'll use
the control's after_update event to run

Call Me.Form_Current
 
G

Gina Whipp

paradise95969,

Have a look at...

http://allenbrowne.com/ser-56.html

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
I'm using a field in the record to lock or unlock another field:

Private Sub Special_Concerns_GotFocus()
If Me.CheckEdit.Value = True Then 'true means edit is ok
Me.ActiveControl.Locked = False
Else: Me.ActiveControl.Locked = True
End If
End Sub

As you can see this is on GotFocus(). I would like to apply this to many
fields. Is there a better way to do it verses adding it to the event
property
for each field separately? I'm assuming there is- but I have not figured
that
out and would like to improve my design where possible.

Thanks
paradise95959
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top