Connecting Tech Pros Worldwide Forums | Help | Site Map

Locking controls on a form

EJO
Guest
 
Posts: n/a
#1: Nov 13 '05
TIA!

I have an A2k mdb which contains a sample record so that my users can
have an online example of input for a any given field. I don't want
them to be able to edit the record, but also do not want to prevent
them from doing a lookup for the live data, so using the allowedits
property doesn't seem to be an option. Is there a way to lock all the
controls without listing the over 60 controls individually, then unlock
the lookup? I tried to use the enumerate controls from the access web
faq, but haven't been able to modify for this purpose.


Grumpy Old Man
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Locking controls on a form


"EJO" <5p1der@centurytel.net> wrote:
[color=blue]
> Is there a way to lock all the
> controls without listing the over 60 controls individually, then unlock
> the lookup? I tried to use the enumerate controls from the access web
> faq, but haven't been able to modify for this purpose.[/color]

This will lock all text boxes, combo boxes, check boxes and option groups:

Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Or TypeOf ctl Is CheckBox Or TypeOf ctl Is
ComboBox Or TypeOf ctl Is OptionGroup Then
ctl.Locked = True
End If
Next

I'm not sure this is the best solution to your problem, I think you'd need
to post more info.

Regards,
Keith.
www.keithwilby.com
deko
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Locking controls on a form


> I have an A2k mdb which contains a sample record so that my users can[color=blue]
> have an online example of input for a any given field. I don't want
> them to be able to edit the record, but also do not want to prevent
> them from doing a lookup for the live data, so using the allowedits
> property doesn't seem to be an option. Is there a way to lock all the
> controls without listing the over 60 controls individually, then unlock
> the lookup? I tried to use the enumerate controls from the access web
> faq, but haven't been able to modify for this purpose.[/color]

If you name your controls with a number suffix (the one you want to lock),
you could put them in a loop. I've done this on occasion.

Private sub LockControls(blnLock as boolean)
Dim ctl as control
For each ctl in Me.Controls
If IsNumeric(Right(ctl.name, 2)) Then ctl.Locked = blnLock
Next
End sub

You could do stuff with different number ranges - like enable or disable.
you might have to check the syntax of my example, but you get the idea...


EJO
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Locking controls on a form


actually, this worked great. thanks for the help!

Arno R
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Locking controls on a form


Maybe just use a 'snapshot' for the forms recordsource and your form will be read-only .
I don't understand what you mean by 'doing a lookup'.
--
Hope this helps
Arno R


"EJO" <5p1der@centurytel.net> schreef in bericht
news:1111074394.837961.253790@o13g2000cwo.googlegr oups.com...[color=blue]
> TIA!
>
> I have an A2k mdb which contains a sample record so that my users can
> have an online example of input for a any given field. I don't want
> them to be able to edit the record, but also do not want to prevent
> them from doing a lookup for the live data, so using the allowedits
> property doesn't seem to be an option. Is there a way to lock all the
> controls without listing the over 60 controls individually, then unlock
> the lookup? I tried to use the enumerate controls from the access web
> faq, but haven't been able to modify for this purpose.
>[/color]


Closed Thread