Also here's a better code sample I've written before for this newsgroup
(using the Form Current, but .. & a Button called EditEnable)
Private Sub Form_Current()
Dim C As Access.Control
For Each C In Me.Controls
Select Case C.ControlType
Case acControlType.acListBox, acControlType.acComboBox,
acControlType.acTextBox, _
acControlType.acCheckBox, acControlType.acBoundObjectFrame, _
acControlType.acObjectFrame, acControlType.acOptionGroup, _
acControlType.acSubform, acControlType.acToggleButton
C.Locked = VBA.IIf(VBA.InStr(C.Tag, "ReadOnly") > 0, Not
Me.EditEnable.Value, C.Locked)
Case acControlType.acCommandButton
C.Enabled = VBA.IIf(VBA.InStr(C.Tag, "ReadOnly") > 0,
Me.EditEnable.Value, C.Enabled)
Case Else ' Don't bother
End Select
Next
End Sub
HTH
Pieter
"Pieter Wijnen"
Can't right now, too busy
try commenting out the On Error resume next to find the error
note "OptLock" must be the same as your toggle button, and should rely
have been referenced properly
Private Sub OptLock_AfterUpdate()
Dim C As Control
Dim tg As String
On Error Resume Next ' Ikke alle kontroller har Tag
For Each C In Me.Controls
tg = VBA.vbNullString
tg = C.Tag
If VBA.InStr(tg,"Lås") Then
C.Locked = Me.OptLock.Value
End If
Next
End Sub
Pieter
david said:
i still can't make i work, maybe you will help (given remote)?
send me an email, and i can give you my ip
"Pieter Wijnen" skrev:
Press [ in the event,
Should bring up [Event Procedure], Click the elipsis (...)
Remember to set the tag property of the controls you want to lock
/Unlock
(Properties, Other, Last item in the list [Tag] )
HTH
Pieter
I have tried it, but i can make it work.
I have insert the code into my codegenerator, but nothing happen when
i
clik, og opdate my form.
"Pieter Wijnen" skrev:
Det kan vi vet du.
Det er lettere å få svar hvis du spør på engelsk
Har dessverre aldri brukt Norsk Eller Dansk MsAccess, så
oversettelsene
er
ikke allverden.
Antar at du har en 'OptionButton' (av /på knapp) med navn OptLock.
For alle kontroller sett 'Tag' (merke?) Egenskapen til teksten "Lås"
Du kan lage følgende kode for 'Etter Oppdatering hendelsen'
(AfterUpdate)
for knappen
Private Sub OptLock_AfterUpdate()
Dim C As Control
Dim tg As String
On Error Resume Next ' Ikke alle kontroller har Tag
For Each C In Me.Controls
tg = VBA.vbNullString
tg = C.Tag
If VBA.InStr(tg,"Lås") Then
C.Locked = OptLock.Value
End If
Next
End Sub
HTH
Pieter
Jeg har søgt, men ikke fundet svar.
Jeg kunne godt tænke mig at lave en knap i en formular, knappen
skulle
helst
være en til/fra-knap, så man kunne låse flere felter op/i.
Jeg håber der er en flink bruger som kan hjælpe mig.