Cant get reference to subform properties in VBA

B

Barry A&P

Because i cant get allen brownes "LockBoundControls" to work with this form.
(although it works wonderfully for me in many other instances) I would like
to disable the record selectors or possibly the allow additions to prevent
copying and pasting a new record to a locked form wich then locks access
because of a index violation wich cant be fixed because the form is locked..
after trying to close the form 10 times a message is finally displayed that
says the record can not be saved and the form closes..

Please see the code below
this line works fine.. Me![F_Parts_Browse_All].Locked = bLock
however all of the others give me a runtime error 438 (object does not
support this property or method.. i feel like i have tried every reference in
the book

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)

If bLock = True Then
Me!cmdLock.Caption = "Un&Lock"
Else
Me!cmdLock.Caption = "&Lock"
End If

'Me.F_Parts_Browse_All.Description.Enabled = Not bLock
'Me![F_Parts_Browse_All].AllowAdditions = False
Me![F_Parts_Browse_All].Locked = bLock
'Me![F_Parts_Browse_All]!Properties.RecordSelectors.Visible = bLock
'Me![F_Parts_Browse_All].AllowEdits = Not bLock

End Sub

Thank you for your help

Barry
 
D

Dirk Goldgar

Barry A&P said:
Because i cant get allen brownes "LockBoundControls" to work with this
form.
(although it works wonderfully for me in many other instances) I would
like
to disable the record selectors or possibly the allow additions to prevent
copying and pasting a new record to a locked form wich then locks access
because of a index violation wich cant be fixed because the form is
locked..
after trying to close the form 10 times a message is finally displayed
that
says the record can not be saved and the form closes..

Please see the code below
this line works fine.. Me![F_Parts_Browse_All].Locked = bLock
however all of the others give me a runtime error 438 (object does not
support this property or method.. i feel like i have tried every reference
in
the book

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)

If bLock = True Then
Me!cmdLock.Caption = "Un&Lock"
Else
Me!cmdLock.Caption = "&Lock"
End If

'Me.F_Parts_Browse_All.Description.Enabled = Not bLock
'Me![F_Parts_Browse_All].AllowAdditions = False
Me![F_Parts_Browse_All].Locked = bLock
'Me![F_Parts_Browse_All]!Properties.RecordSelectors.Visible = bLock
'Me![F_Parts_Browse_All].AllowEdits = Not bLock

End Sub


You're making the mistake of trying to manipulate properties of the subform
*control* (on the main form), rather than the properties of the form object
that control displays. Try this.

Me.F_Parts_Browse_All.Form!Description.Enabled = Not bLock
Me![F_Parts_Browse_All].Form.AllowAdditions = False
Me![F_Parts_Browse_All].Locked = bLock
Me![F_Parts_Browse_All].Form.RecordSelectors = Not bLock
Me![F_Parts_Browse_All].Form.AllowEdits = Not bLock

If you weren't able to get Allen's LockBoundControls to work on this
form/subform, maybe you were having a similar problem with that code --
trying to run it against the subform control rather than the subform
control's .Form object.
 
B

Barry A&P

Dirk

Thank you for your response...

unfortunately none of the references worked i get the runtime 2455 error
"you entered an expression that has an invalid reference to a form/property"

However this line works fine... Me![F_Parts_Browse_All].Locked = bLock

and as i understand Allen's LockBoundControls module creates its own
references and also locks all controls on all subforms (wich it does on all
of my forms & subforms except this one).

Im completely lost on this one and cant seem to proceed.. could there be
some kind of issue with my form???

Thanks for any more help.

Barry

Dirk Goldgar said:
Barry A&P said:
Because i cant get allen brownes "LockBoundControls" to work with this
form.
(although it works wonderfully for me in many other instances) I would
like
to disable the record selectors or possibly the allow additions to prevent
copying and pasting a new record to a locked form wich then locks access
because of a index violation wich cant be fixed because the form is
locked..
after trying to close the form 10 times a message is finally displayed
that
says the record can not be saved and the form closes..

Please see the code below
this line works fine.. Me![F_Parts_Browse_All].Locked = bLock
however all of the others give me a runtime error 438 (object does not
support this property or method.. i feel like i have tried every reference
in
the book

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)

If bLock = True Then
Me!cmdLock.Caption = "Un&Lock"
Else
Me!cmdLock.Caption = "&Lock"
End If

'Me.F_Parts_Browse_All.Description.Enabled = Not bLock
'Me![F_Parts_Browse_All].AllowAdditions = False
Me![F_Parts_Browse_All].Locked = bLock
'Me![F_Parts_Browse_All]!Properties.RecordSelectors.Visible = bLock
'Me![F_Parts_Browse_All].AllowEdits = Not bLock

End Sub


You're making the mistake of trying to manipulate properties of the subform
*control* (on the main form), rather than the properties of the form object
that control displays. Try this.

Me.F_Parts_Browse_All.Form!Description.Enabled = Not bLock
Me![F_Parts_Browse_All].Form.AllowAdditions = False
Me![F_Parts_Browse_All].Locked = bLock
Me![F_Parts_Browse_All].Form.RecordSelectors = Not bLock
Me![F_Parts_Browse_All].Form.AllowEdits = Not bLock

If you weren't able to get Allen's LockBoundControls to work on this
form/subform, maybe you were having a similar problem with that code --
trying to run it against the subform control rather than the subform
control's .Form object.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top