Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking form fields 2

Status
Not open for further replies.

Richey

Technical User
Aug 29, 2000
121
GB
Hi

I have a form with approx. 60 fields on (mainly text - some combo)
When the user enters a completion date, I have the form running a function which says
allowedits = false

The problem is I want one of the text fields to remain editable?
I know I could say, for each of the fields
me.field.locked = true
bar the one field, but that seems long-winded

any ideas?
Ta

Connor
 
Hi Conner!

Try this:

Dim cntl An Control

For Each cntl in Me.Controls
If cntl.Name <> &quot;YourControlName&quot; And cntl.ControlType <> acLabel Then
cnlt.Enabled = False
End If
Next cntl

Set cntl = Nothing

hth
Jeff Bridgham
bridgham@purdue.edu
 
Well I don't know the exact VB code. I'm sure someone else here can post it, but here's one efficient way to do it.

Use loop to lock all fields and then unlock the 1 field after the loop. Maq B-)
<insert witty signature here>
 
speedtyper Jeff beat me to it. Maq B-)
<insert witty signature here>
 
Cheers Jeff

Sounds good, but I'm getting an error message saying
'Object doesn't support this property or method' for line
cntl.enabled = false

Connor


 
What types of controls are on your form. Not all controls support the enabled/disabled property. For example labels (which Jeff's code excludes) and images. Just tweak Jeff's code to exclude any control types on your form which aren't &quot;clickable&quot; or updatable Maq B-)
<insert witty signature here>
 
Hi Maq!

Thanks for the help. And you call me a speedtyper!
:) Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top