473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Locking ONLY the subform

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
10 2932
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Craig M | last post by:
Hi, I have 2 forms, frmretailorders, and frmretailorderline. in the oncurrent of the main form, I check what the value of !status is. If it is "complete", then i disable all text and combo...
0
by: ethanj /personal/ | last post by:
I have main form with subform, similar to the Order Details form in the Northwind database. The the main form record locking is released when I click to edit subform's records. Is there away to...
4
by: Peter Bailey | last post by:
I have a subform that I dont want to have a recordsource initially as it is locking the table that is created dynamically. I want to connect to the table after the data has been written by another...
8
by: ken | last post by:
Hi, I have a form that depending on certain criteria locks all of the subforms on this form. The problem is when the code unlocks the subforms their "allowedits" "allowdeletions" and...
1
by: Moha | last post by:
I have form Orders and Subform Technical info. The Ordrs form is connected to query (multiple table) and the Technicl subform is connected to one table. I have divided the technical table into...
9
by: ApexData | last post by:
My main form has tab-pages. On each tabbed page is a subform control containing a different subform. When a user selects a specific tab and begins to edit a record, I need a way of preventing the...
3
by: eyalco | last post by:
I'm creating an invoice software (access 2000) in which most of it is over. Need to consult which is the best way to lock form and subform after saving and printing. The code I think of using is :...
0
by: Andy_Khosravi | last post by:
I'm having issues with updates being blocked due to some sort of record locking issue. The error does not occur consistently, so I've had a hard time nailing it down. It does happen enough to cause...
10
by: Jesse Jones | last post by:
I currently have an access database that is a 2007 file that is operated through Access 2010. It has as many as fifty users on it at any given time. All of the user's workstations are set to lock...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.