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

locking subforms

P: n/a
ken
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 "allowadditions"
properties are set to "NO". I believe when the main form locks the
subforms it sets these "allow" properties to "no". But when the
subforms are unlocked the "allow" properties are not set back to "yes".
I have all this code in the oncurrent event. Depending on the record
that I'm in, the form is either locked or not.

Anyhow I tried setting the "allow" properties to yes during the unlock
opperation, but access gives me an error stating that the subforms
don't have the allow properties...

what am I doing wrong?

thanks

Nov 13 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a

"ken" <ge****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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 "allowadditions"
properties are set to "NO". I believe when the main form locks the
subforms it sets these "allow" properties to "no". But when the
subforms are unlocked the "allow" properties are not set back to "yes".
I have all this code in the oncurrent event. Depending on the record
that I'm in, the form is either locked or not.

Anyhow I tried setting the "allow" properties to yes during the unlock
opperation, but access gives me an error stating that the subforms
don't have the allow properties...

what am I doing wrong?

thanks


Just a suggestion Ken, but if you post your code there's a much better
chance that someone will be able to tell you what is wrong with it.

Nov 13 '05 #2

P: n/a
ken
Private Sub Form_Current()
If ([islocked]) Then
'if true lock form
Me.AllowEdits = False
Me.AllowDeletions = False
Me.AllowAdditions = False
Me![Input subform].Locked = True
Else
'if false unlock form
Me.AllowEdits = True
Me.AllowDeletions = True
Me.AllowAdditions = True
Me![Input subform].Locked = False
End If
End Sub
Basically when the if statement is false I could not do any data entry
on the subform. I could on the main form though...I was looking through
the properties while the form was on...and all the allow properties had
a "No" in them...so I tried this:

Private Sub Form_Current()
If ([islocked]) Then
'if true lock form
Me.AllowEdits = False
Me.AllowDeletions = False
Me.AllowAdditions = False
Me![Input subform].Locked = True
Else
'if false unlock form
Me.AllowEdits = True
Me.AllowDeletions = True
Me.AllowAdditions = True
Me![Input subform].Locked = False
Me![Input subform].AllowEdits = True
End If
End Sub
And I got error stating that the Me![Input subform] does not have an
allowedits property...

Nov 13 '05 #3

P: n/a
doesn't look like you're referring to the subform properly. Here's an
article that gives examples of referring to just about everything in
forms and subforms.

http://www.mvps.org/access/forms/frm0031.htm

I think this is the syntax that you want:

Me!Subform1.Form.AllowEdits=True

Nov 13 '05 #4

P: n/a

"ken" <ge****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Private Sub Form_Current()
If ([islocked]) Then
'if true lock form
Me.AllowEdits = False
Me.AllowDeletions = False
Me.AllowAdditions = False
Me![Input subform].Locked = True
Else
'if false unlock form
Me.AllowEdits = True
Me.AllowDeletions = True
Me.AllowAdditions = True
Me![Input subform].Locked = False
End If
End Sub
Basically when the if statement is false I could not do any data entry
on the subform. I could on the main form though...I was looking through
the properties while the form was on...and all the allow properties had
a "No" in them...so I tried this:

Private Sub Form_Current()
If ([islocked]) Then
'if true lock form
Me.AllowEdits = False
Me.AllowDeletions = False
Me.AllowAdditions = False
Me![Input subform].Locked = True
Else
'if false unlock form
Me.AllowEdits = True
Me.AllowDeletions = True
Me.AllowAdditions = True
Me![Input subform].Locked = False
Me![Input subform].AllowEdits = True
End If
End Sub
And I got error stating that the Me![Input subform] does not have an
allowedits property...


Ken, I'm only guessing here, but I suspect that the procedure you are using
is in the parent form, not the sub form. AllowEdits only applies to forms,
not controls on forms, even sub form controls. To allow edits you will need
to refer directly to the form with something like:

Forms![Input subform].AllowEdits = True

HTH

Nov 13 '05 #5

P: n/a
ken
ok I think that did it I have to do
Me![Input subform].Form.AllowEdits = True

then it works

Nov 13 '05 #6

P: n/a
ken
does anyone know though why when you lock the form with .locked = true
it sets all the allow properties to No, but when you unlock it does not
set them back to yes?

Nov 13 '05 #7

P: n/a
"ken" <ge****@gmail.com> wrote in
news:11**********************@z14g2000cwz.googlegr oups.com:
ok I think that did it I have to do
Me![Input subform].Form.AllowEdits = True

then it works


The reason it works is because there's a distinction between the
subform control that you place on a form and the actual subform
contained in the subform control.

If you turn off the wizards in form design, you can drop an empty
subform control on a form. It has no Source Object property.

The subform control has its own set of properties, separate from
those of the subform that it is holding once you assign a Source
Object property.

Versions of Access since 2000 obscure this because of the brain-dead
stupid interface that displays the subform in the control itself at
all times (making it impossible to easily edit that form in
instances where the size of the control is too small to fully
display the design view of the form; this includes EVERY SUBFORM
EVER, since the design view requires more screen real estate than
the form view in all cases), but it's still there.

Me![Input subform] is the subform control.

whereas:

Me![Input subform].Form is the form displayed in that subform
control.

I make a point of naming subforms subMyForm and the subform control
MyForm to remind myself that MyForm is *not* itself a form, but a
subform control.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8

P: 5
Hi, I also have a problem with subforms but what I want to do is slightly different. I want to lock a subform until all the required data is inputted in the main form.

The required fields in main form:
Invoice Number
Invoice to

Thank you
Mar 29 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.