help with allen brownes Lock bound controls

B

Barry A&P

I am using allen browns lock bound controls code. I have used it elsewhere in
my database just fine however i would like to use it on a unbound search form
the button ctlLock is on my main unbound form and i want it to toggle and
lock my results subform

here is the line i am having issues with i think it is because i am trying
to reference the subform incorrectly..

Call LockBoundControls(Me.F_Parts_Browse_All, bLock)
i get a runtime error 13 Type mismatch on the above line

I f i leave the ME as supplied by allen Call LockBoundControls(Me, bLock)
i get a error 2455 for invalid reference to expression Dirty maybe because
my main form is unbound??

i have tried
forms_F_parts_Browse_all
forms!F_parts_Browse_all
me!F_parts_Browse_all
Forms!F_Parts_Search!F_parts_Browse_all
and just about every other combo i can think of
Any help would be greatly appreciated
Thanks
Barry
 
J

Jack Leach

Call LockBoundControls(Me.F_Parts_Browse_All, bLock)

The argument expects a form rather than control. Try this instead...

Call LockBoundControls(Me.F-Parts_Browse_All.Form, bLock)

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
B

Barry A&P

I Have tried both of these and i get a invalid reference error

Option Compare Database

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(Forms.F_Parts_Search.F_Parts_Browse_All.Form,
bLock)
End Sub

and

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(me.F_Parts_Browse_All.Form, bLock)
End Sub

Thanks for trying

Barry
 
A

Allen Browne

That's not the same as Jack suggested, as subforms are not part of the Forms
collection.

Try:
Call LockBoundControls(Me.F_Parts_Search.F_Parts_Browse_All.Form, bLock)
 
B

Barry A&P

Allen
With the following code i get the error Method or data member not found
with this text
This error occurs when an event has failed to run because Microsoft Office
Access cannot evaluate the location of the logic for the event. For example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is fired.


Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(Me.F_Parts_Search.F_Parts_Browse_All.Form, bLock)
End Sub

i even tried re-copying your entire module to a blank database with two
simple forms

and this didnt work either
Private Sub cmdlock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdlock.Caption = "&Lock", True, False)
Call LockBoundControls(Me.form1.Form2.Forms, bLock)
End Sub

i can send you the simple database??

thanks Barry
 

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