A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Running same code on many fields...



 
 
Thread Tools Display Modes
  #1  
Old January 25th, 2010, 10:41 PM posted to microsoft.public.access.forms
paradise95969
external usenet poster
 
Posts: 1
Default Running same code on many fields...

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

  #2  
Old January 26th, 2010, 12:57 AM posted to microsoft.public.access.forms
Bob Quintal
external usenet poster
 
Posts: 939
Default Running same code on many fields...

"paradise95969" u57765@uwe wrote in news:a2a8165fcc0c7@uwe:

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

--
Bob Quintal

PA is y I've altered my email address.
  #3  
Old January 26th, 2010, 02:05 AM posted to microsoft.public.access.forms
Gina Whipp
external usenet poster
 
Posts: 3,500
Default Running same code on many fields...

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
"paradise95969" u57765@uwe wrote in message news:a2a8165fcc0c7@uwe...
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


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:26 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.