By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,209 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,209 IT Pros & Developers. It's quick & easy.

Locking ONLY the subform

P: n/a
Ami
Hello everyone,

I have developed a small access application and now I need to lock my
forms against unwanted edits.

I have used the code by Allen Browne I found here
http://allenbrowne.com/ser-56.html

and it works great, but I need to unlock and lock my main form and
subform separately, using two different buttons.

The main form is working OK, but I cannot get the part about the
subform to work independently, i.e. I cannot change the code so that
the subform is locked even if the mainform is unlocked and vice versa.

This is the code I am using:

==============================
Public Function LockBoundControls(frm As Form, bLock As Boolean,
ParamArray avarExceptionList())
On Error GoTo Err_Handler
'Purpose: Lock the bound controls and prevent deletes on the
form any its subforms.
'Arguments frm = the form to be locked
' bLock = True to lock, False to unlock.
' avarExceptionList: Names of the controls NOT to lock
(variant array of strings).
'Usage: Call LockBoundControls(Me. True)
Dim ctl As Control 'Each control on the form
Dim lngI As Long 'Loop controller.
Dim bSkip As Boolean

'Save any edits.
If frm.Dirty Then
frm.Dirty = False
End If
'Block deletions.
frm.AllowDeletions = Not bLock

For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup,
acCheckBox, acOptionButton, acToggleButton
'Lock/unlock these controls if bound to fields.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If HasProperty(ctl, "ControlSource") Then
If Len(ctl.ControlSource) > 0 And Not
ctl.ControlSource Like "=*" Then
If ctl.Locked <> bLock Then
ctl.Locked = bLock
End If
End If
End If
End If

Case acSubform
'Recursive call to handle all subforms.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If Len(Nz(ctl.SourceObject, vbNullString)) > 0 Then
ctl.Form.AllowDeletions = Not bLock
ctl.Form.AllowAdditions = Not bLock
Call LockBoundControls(ctl.Form, bLock)
End If
End If

Case acLabel, acLine, acRectangle, acCommandButton, acTabCtl,
acPage, acPageBreak, acImage, acObjectFrame
'Do nothing

Case Else
'Includes acBoundObjectFrame, acCustomControl
Debug.Print ctl.Name & " not handled " & Now()
End Select
Next

'Set the visual indicators on the form.
On Error Resume Next
frm.cmdLock.Caption = IIf(bLock, "Un&lock", "&Lock")
frm!rctLock.Visible = bLock
Exit_Handler:
Set ctl = Nothing
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description
Resume Exit_Handler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As
Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant
On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function
===========================================
How do I need to change the code?

Thanks in advance for any help!

Bye from Italy

Erika
Jun 4 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
From where are you calling these procedures, and how are you passing the
reference to the Form embedded in the Subform Control?

"cannot get the part about the subform to work independently" is very
non-specific, so you could help us help you by explaining (in addition to
the above) what you expect to happen, and exactly what _is_ happening.

Larry Linson
Microsoft Access MVP

"Ami" <am**********************************@yahoo.com> wrote in message
news:h3********************************@4ax.com...
Hello everyone,

I have developed a small access application and now I need to lock my
forms against unwanted edits.

I have used the code by Allen Browne I found here
http://allenbrowne.com/ser-56.html

and it works great, but I need to unlock and lock my main form and
subform separately, using two different buttons.

The main form is working OK, but I cannot get the part about the
subform to work independently, i.e. I cannot change the code so that
the subform is locked even if the mainform is unlocked and vice versa.

This is the code I am using:

==============================
Public Function LockBoundControls(frm As Form, bLock As Boolean,
ParamArray avarExceptionList())
On Error GoTo Err_Handler
'Purpose: Lock the bound controls and prevent deletes on the
form any its subforms.
'Arguments frm = the form to be locked
' bLock = True to lock, False to unlock.
' avarExceptionList: Names of the controls NOT to lock
(variant array of strings).
'Usage: Call LockBoundControls(Me. True)
Dim ctl As Control 'Each control on the form
Dim lngI As Long 'Loop controller.
Dim bSkip As Boolean

'Save any edits.
If frm.Dirty Then
frm.Dirty = False
End If
'Block deletions.
frm.AllowDeletions = Not bLock

For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup,
acCheckBox, acOptionButton, acToggleButton
'Lock/unlock these controls if bound to fields.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If HasProperty(ctl, "ControlSource") Then
If Len(ctl.ControlSource) > 0 And Not
ctl.ControlSource Like "=*" Then
If ctl.Locked <> bLock Then
ctl.Locked = bLock
End If
End If
End If
End If

Case acSubform
'Recursive call to handle all subforms.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If Len(Nz(ctl.SourceObject, vbNullString)) > 0 Then
ctl.Form.AllowDeletions = Not bLock
ctl.Form.AllowAdditions = Not bLock
Call LockBoundControls(ctl.Form, bLock)
End If
End If

Case acLabel, acLine, acRectangle, acCommandButton, acTabCtl,
acPage, acPageBreak, acImage, acObjectFrame
'Do nothing

Case Else
'Includes acBoundObjectFrame, acCustomControl
Debug.Print ctl.Name & " not handled " & Now()
End Select
Next

'Set the visual indicators on the form.
On Error Resume Next
frm.cmdLock.Caption = IIf(bLock, "Un&lock", "&Lock")
frm!rctLock.Visible = bLock
Exit_Handler:
Set ctl = Nothing
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description
Resume Exit_Handler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As
Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant
On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function
===========================================
How do I need to change the code?

Thanks in advance for any help!

Bye from Italy

Erika

Jun 5 '06 #2

P: n/a
If you want to use 2 separate buttons for locking the main form and the
subform independently:
a) Name the subform control as an exception in the button that handles the
main form, e.g.:
Call LockBoundControls(Me, bLock, "Sub1")

b) Refer to the subform in the button that handles the subform, e.g.:
Call LockBoundControls(Me.[Sub1].Form, bLock)

The examples assume your subform control is named Sub1, and both command
buttons are on the main form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Ami" <am**********************************@yahoo.com> wrote in message
news:h3********************************@4ax.com...
Hello everyone,

I have developed a small access application and now I need to lock my
forms against unwanted edits.

I have used the code by Allen Browne I found here
http://allenbrowne.com/ser-56.html

and it works great, but I need to unlock and lock my main form and
subform separately, using two different buttons.

The main form is working OK, but I cannot get the part about the
subform to work independently, i.e. I cannot change the code so that
the subform is locked even if the mainform is unlocked and vice versa.

This is the code I am using:

==============================
Public Function LockBoundControls(frm As Form, bLock As Boolean,
ParamArray avarExceptionList())
On Error GoTo Err_Handler
'Purpose: Lock the bound controls and prevent deletes on the
form any its subforms.
'Arguments frm = the form to be locked
' bLock = True to lock, False to unlock.
' avarExceptionList: Names of the controls NOT to lock
(variant array of strings).
'Usage: Call LockBoundControls(Me. True)
Dim ctl As Control 'Each control on the form
Dim lngI As Long 'Loop controller.
Dim bSkip As Boolean

'Save any edits.
If frm.Dirty Then
frm.Dirty = False
End If
'Block deletions.
frm.AllowDeletions = Not bLock

For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup,
acCheckBox, acOptionButton, acToggleButton
'Lock/unlock these controls if bound to fields.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If HasProperty(ctl, "ControlSource") Then
If Len(ctl.ControlSource) > 0 And Not
ctl.ControlSource Like "=*" Then
If ctl.Locked <> bLock Then
ctl.Locked = bLock
End If
End If
End If
End If

Case acSubform
'Recursive call to handle all subforms.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If Len(Nz(ctl.SourceObject, vbNullString)) > 0 Then
ctl.Form.AllowDeletions = Not bLock
ctl.Form.AllowAdditions = Not bLock
Call LockBoundControls(ctl.Form, bLock)
End If
End If

Case acLabel, acLine, acRectangle, acCommandButton, acTabCtl,
acPage, acPageBreak, acImage, acObjectFrame
'Do nothing

Case Else
'Includes acBoundObjectFrame, acCustomControl
Debug.Print ctl.Name & " not handled " & Now()
End Select
Next

'Set the visual indicators on the form.
On Error Resume Next
frm.cmdLock.Caption = IIf(bLock, "Un&lock", "&Lock")
frm!rctLock.Visible = bLock
Exit_Handler:
Set ctl = Nothing
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description
Resume Exit_Handler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As
Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant
On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function
===========================================
How do I need to change the code?

Thanks in advance for any help!

Bye from Italy

Erika

Jun 5 '06 #3

P: n/a
Hi!, thanks for the help.
Allen Browne ha scritto:
If you want to use 2 separate buttons for locking the main form and the
subform independently:
Yes.
a) Name the subform control as an exception in the button that handles the
main form, e.g.:
Call LockBoundControls(Me, bLock, "Sub1")

b) Refer to the subform in the button that handles the subform, e.g.:
Call LockBoundControls(Me.[Sub1].Form, bLock)

The examples assume your subform control is named Sub1, and both command
buttons are on the main form.


Ok, thanks for the explanation!
I am at work now and cannot try. As soon as I get back home I am
trying.

Thanks again for the help!

Erika

Jun 5 '06 #4

P: n/a
Ami
On Mon, 5 Jun 2006 12:49:23 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
If you want to use 2 separate buttons for locking the main form and the
subform independently:
a) Name the subform control as an exception in the button that handles the
main form, e.g.:
Call LockBoundControls(Me, bLock, "Sub1")

b) Refer to the subform in the button that handles the subform, e.g.:
Call LockBoundControls(Me.[Sub1].Form, bLock)

The examples assume your subform control is named Sub1, and both command
buttons are on the main form.
Hi, I'm finally back home. Thanks again for the help

I tried what you suggested and it works ok... but I can't get the part
about the visual indicators on the form right.

I guess that if I am going to switch the lock on the main and subform
on and off using two different buttons on the main form, I'll also
need two visual indicators if I want to "see" when 1 of the forms is
locked or both.

I'd also need the two visual indicators because I check the .visible
property of the rectangle to fire a msgbx before locking the forms
again.

I tried creating a second rectangle calling it rctLock2 and it does
work, but - of course - if the main form is unlocked the thing with
the subform won't work

I also wanted to add that the form is always locked whenever I open
it. I use this code:

Private Sub Form_Open(Cancel As Integer)
Call LockBoundControls([Form], True)
End Sub

I hope I managed to convey my problem... I'm not a native English
speaker and it can be tricky and difficult when you need to get into
technical details.

Thanks again

Erika
"Ami" <am**********************************@yahoo.com> wrote in
message
news:h3********************************@4ax.com... Hello everyone,

I have developed a small access application and now I need to lock my
forms against unwanted edits.

I have used the code by Allen Browne I found here
http://allenbrowne.com/ser-56.html

and it works great, but I need to unlock and lock my main form and
subform separately, using two different buttons.

The main form is working OK, but I cannot get the part about the
subform to work independently, i.e. I cannot change the code so that
the subform is locked even if the mainform is unlocked and vice versa.

This is the code I am using:

==============================
Public Function LockBoundControls(frm As Form, bLock As Boolean,
ParamArray avarExceptionList())
On Error GoTo Err_Handler
'Purpose: Lock the bound controls and prevent deletes on the
form any its subforms.
'Arguments frm = the form to be locked
' bLock = True to lock, False to unlock.
' avarExceptionList: Names of the controls NOT to lock
(variant array of strings).
'Usage: Call LockBoundControls(Me. True)
Dim ctl As Control 'Each control on the form
Dim lngI As Long 'Loop controller.
Dim bSkip As Boolean

'Save any edits.
If frm.Dirty Then
frm.Dirty = False
End If
'Block deletions.
frm.AllowDeletions = Not bLock

For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup,
acCheckBox, acOptionButton, acToggleButton
'Lock/unlock these controls if bound to fields.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If HasProperty(ctl, "ControlSource") Then
If Len(ctl.ControlSource) > 0 And Not
ctl.ControlSource Like "=*" Then
If ctl.Locked <> bLock Then
ctl.Locked = bLock
End If
End If
End If
End If

Case acSubform
'Recursive call to handle all subforms.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If Len(Nz(ctl.SourceObject, vbNullString)) > 0 Then
ctl.Form.AllowDeletions = Not bLock
ctl.Form.AllowAdditions = Not bLock
Call LockBoundControls(ctl.Form, bLock)
End If
End If

Case acLabel, acLine, acRectangle, acCommandButton, acTabCtl,
acPage, acPageBreak, acImage, acObjectFrame
'Do nothing

Case Else
'Includes acBoundObjectFrame, acCustomControl
Debug.Print ctl.Name & " not handled " & Now()
End Select
Next

'Set the visual indicators on the form.
On Error Resume Next
frm.cmdLock.Caption = IIf(bLock, "Un&lock", "&Lock")
frm!rctLock.Visible = bLock
Exit_Handler:
Set ctl = Nothing
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description
Resume Exit_Handler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As
Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant
On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function
===========================================
How do I need to change the code?

Thanks in advance for any help!

Bye from Italy

Erika

Jun 5 '06 #5

P: n/a
The routine looks for a rectangle named rctLock on the form it is locking.
Try adding a rectangle with that name to the software.

To unlock the form, use False instead of True for the 2nd argument, i.e.:
Call LockBoundControls([Form], False)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Ami" <am**********************************@yahoo.com> wrote in message
news:s5********************************@4ax.com...
On Mon, 5 Jun 2006 12:49:23 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
If you want to use 2 separate buttons for locking the main form and the
subform independently:
a) Name the subform control as an exception in the button that handles the
main form, e.g.:
Call LockBoundControls(Me, bLock, "Sub1")

b) Refer to the subform in the button that handles the subform, e.g.:
Call LockBoundControls(Me.[Sub1].Form, bLock)

The examples assume your subform control is named Sub1, and both command
buttons are on the main form.


Hi, I'm finally back home. Thanks again for the help

I tried what you suggested and it works ok... but I can't get the part
about the visual indicators on the form right.

I guess that if I am going to switch the lock on the main and subform
on and off using two different buttons on the main form, I'll also
need two visual indicators if I want to "see" when 1 of the forms is
locked or both.

I'd also need the two visual indicators because I check the .visible
property of the rectangle to fire a msgbx before locking the forms
again.

I tried creating a second rectangle calling it rctLock2 and it does
work, but - of course - if the main form is unlocked the thing with
the subform won't work

I also wanted to add that the form is always locked whenever I open
it. I use this code:

Private Sub Form_Open(Cancel As Integer)
Call LockBoundControls([Form], True)
End Sub

I hope I managed to convey my problem... I'm not a native English
speaker and it can be tricky and difficult when you need to get into
technical details.

Thanks again

Erika
"Ami" <am**********************************@yahoo.com> wrote in
message
news:h3********************************@4ax.com...
Hello everyone,

I have developed a small access application and now I need to lock my
forms against unwanted edits.

I have used the code by Allen Browne I found here
http://allenbrowne.com/ser-56.html

and it works great, but I need to unlock and lock my main form and
subform separately, using two different buttons.

The main form is working OK, but I cannot get the part about the
subform to work independently, i.e. I cannot change the code so that
the subform is locked even if the mainform is unlocked and vice versa.

This is the code I am using:

==============================
Public Function LockBoundControls(frm As Form, bLock As Boolean,
ParamArray avarExceptionList())
On Error GoTo Err_Handler
'Purpose: Lock the bound controls and prevent deletes on the
form any its subforms.
'Arguments frm = the form to be locked
' bLock = True to lock, False to unlock.
' avarExceptionList: Names of the controls NOT to lock
(variant array of strings).
'Usage: Call LockBoundControls(Me. True)
Dim ctl As Control 'Each control on the form
Dim lngI As Long 'Loop controller.
Dim bSkip As Boolean

'Save any edits.
If frm.Dirty Then
frm.Dirty = False
End If
'Block deletions.
frm.AllowDeletions = Not bLock

For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup,
acCheckBox, acOptionButton, acToggleButton
'Lock/unlock these controls if bound to fields.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If HasProperty(ctl, "ControlSource") Then
If Len(ctl.ControlSource) > 0 And Not
ctl.ControlSource Like "=*" Then
If ctl.Locked <> bLock Then
ctl.Locked = bLock
End If
End If
End If
End If

Case acSubform
'Recursive call to handle all subforms.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If Len(Nz(ctl.SourceObject, vbNullString)) > 0 Then
ctl.Form.AllowDeletions = Not bLock
ctl.Form.AllowAdditions = Not bLock
Call LockBoundControls(ctl.Form, bLock)
End If
End If

Case acLabel, acLine, acRectangle, acCommandButton, acTabCtl,
acPage, acPageBreak, acImage, acObjectFrame
'Do nothing

Case Else
'Includes acBoundObjectFrame, acCustomControl
Debug.Print ctl.Name & " not handled " & Now()
End Select
Next

'Set the visual indicators on the form.
On Error Resume Next
frm.cmdLock.Caption = IIf(bLock, "Un&lock", "&Lock")
frm!rctLock.Visible = bLock
Exit_Handler:
Set ctl = Nothing
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description
Resume Exit_Handler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As
Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant
On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function
===========================================
How do I need to change the code?

Thanks in advance for any help!

Bye from Italy

Erika

Jun 6 '06 #6

P: n/a
Ami
On Tue, 6 Jun 2006 08:27:19 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
The routine looks for a rectangle named rctLock on the form it is locking.
Try adding a rectangle with that name to the software.

To unlock the form, use False instead of True for the 2nd argument, i.e.:
Call LockBoundControls([Form], False)

OK, that's what I did.

But what I'd really like to do is to use two rectangles: I use the
rectangle to see at a glance wether the form/subform are unlocked or
not.

If I only have one rectangle, whenever I unlock the first form (or the
subform), then I have no visual check for the second one.

So I'm wondering if it's possible to add a second rectangle and make
it visible/invisible like I do with the first one.

Thanks

Erika
Jun 6 '06 #7

P: n/a
Sure.

Just put the rectangle in the subform, assuming it is a Continuous subform
(not datasheet).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Ami" <am**********************************@yahoo.com> wrote in message
news:p9********************************@4ax.com...
On Tue, 6 Jun 2006 08:27:19 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
The routine looks for a rectangle named rctLock on the form it is locking.
Try adding a rectangle with that name to the software.

To unlock the form, use False instead of True for the 2nd argument, i.e.:
Call LockBoundControls([Form], False)

OK, that's what I did.

But what I'd really like to do is to use two rectangles: I use the
rectangle to see at a glance wether the form/subform are unlocked or
not.

If I only have one rectangle, whenever I unlock the first form (or the
subform), then I have no visual check for the second one.

So I'm wondering if it's possible to add a second rectangle and make
it visible/invisible like I do with the first one.

Thanks

Erika

Jun 7 '06 #8

P: n/a
Sorry for the different nick, but I'm posting from work...
Sure.

Just put the rectangle in the subform, assuming it is a Continuous subform
(not datasheet).
Unfortunately it is a datasheet.
The mainform refers to the customers and the subform is listing all the
orders they placed in the past.

Thanks

Erika
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Ami" <am**********************************@yahoo.com> wrote in message
news:p9********************************@4ax.com...
On Tue, 6 Jun 2006 08:27:19 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
The routine looks for a rectangle named rctLock on the form it is locking.
Try adding a rectangle with that name to the software.

To unlock the form, use False instead of True for the 2nd argument, i.e.:
Call LockBoundControls([Form], False)

OK, that's what I did.

But what I'd really like to do is to use two rectangles: I use the
rectangle to see at a glance wether the form/subform are unlocked or
not.

If I only have one rectangle, whenever I unlock the first form (or the
subform), then I have no visual check for the second one.

So I'm wondering if it's possible to add a second rectangle and make
it visible/invisible like I do with the first one.

Thanks

Erika


Jun 7 '06 #9

P: n/a
Ami
On Wed, 7 Jun 2006 08:43:06 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Sure.

Just put the rectangle in the subform, assuming it is a Continuous subform
(not datasheet).


Hi!

I just wanted to let you know that I finally solved the "puzzle". It's
not really an "elegant" way of doing things, but it does work, so I
guess it's OK.

I am still using your module, but I am using it twice.

First I use Call LockBoundControls(Me, bLock, "Sub1") and use 1 red
rectangle.

Then I use Call LockBoundControls2(Me, bLock, "Main") and use 1 blue
rectangle.

In this way I can use the two controls independently on the same form
and I also have the two rectangles, just as I needed, so that I can
trigger events basing on the visible/invisible status of the
rectangle.

In this way I only need to use 1 form+subform instead of 3+3 as before
and having both the form and the subform locked saves a lot of
checkings on other events.

Now everything works as a charm (at least until I decide to add some
other function I like and I certainly don't know how to implement).

Thanks again for the help and for pointing me in the right direction!

Erika
Jun 10 '06 #10

P: n/a
Good news.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Ami" <am**********************************@yahoo.com> wrote in message
news:u7********************************@4ax.com...
Hi!

I just wanted to let you know that I finally solved the "puzzle"...

Jun 11 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.