PC Review


Reply
Thread Tools Rate Thread

Cant get reference to subform properties in VBA

 
 
Barry A&P
Guest
Posts: n/a
 
      20th May 2010
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
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      20th May 2010
"Barry A&P" <(E-Mail Removed)> wrote in message
news:6C60DDC0-6410-4B0F-8665-(E-Mail Removed)...
> 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)

 
Reply With Quote
 
Barry A&P
Guest
Posts: n/a
 
      25th May 2010
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" wrote:

> "Barry A&P" <(E-Mail Removed)> wrote in message
> news:6C60DDC0-6410-4B0F-8665-(E-Mail Removed)...
> > 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)
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference a control on a subform that is on a subform gsnidow via AccessMonster.com Microsoft Access Form Coding 3 7th Mar 2008 06:04 PM
Syntax to reference subform from other subform on split-form in 2007 JC Microsoft Access Form Coding 0 11th Mar 2007 06:07 AM
Subform properties =?Utf-8?B?YWw5MzE1?= Microsoft Access Queries 1 14th Feb 2005 07:36 PM
Subform changes properties all by itself... Gary W. Graley Microsoft Access Forms 2 20th Mar 2004 07:58 PM
Subform changes properties all by itself... Gary W. Graley Microsoft Access Forms 0 19th Mar 2004 02:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:09 PM.