Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't edit subform 2

Status
Not open for further replies.

pmo

Technical User
Jan 15, 2001
76
AU
I have a form called "ParentF" with a datasheet subform called "ChildSubF". "ChildSubF" has all allow edit,filters, deletes etc set to "yes". My "ParentF" has allow edit set to "No".
On opening, both parent and child forms aren't editable which is the way I want it.
I have created a button and attached the following basic code to enable the user editability after clicking the button.

Private Sub Command41_Click()
Me.AllowEdits = True
End Sub

This allows all of the fields on the "ParentF" to be edited but the fields in the subform remain locked.
Is there away to allow the sub form to be editable as well.

Thanks in anticipation.
 
Yes, do the same thing to the sub form that you have done to the parent form


I.E.
Code:
Private Sub Command41_Click()
Me.AllowEdits = True
Me!subfrmControlName.Form.AllowEdits = True
End Sub

Replace subfrmControlName with the name of the sub form control that contains the subform ChildSubF



'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
LittleSmudge,
Thanks for the information. It works fine.
I tried part of this previously but with little success. I was leaving out the .Form section of the code.
What does the .Form mean or do?
 
The full syntax is

To refer to a ontrol on a subform
Forms!FormName!subfrmControlName.Form!ControlName

Forms
I'm refering to a member of the Forms collection in the database

!FormName
The name of the specific form

Forms!FormName can be abreviated to Me in the local form


!subfrmcontrolName
The name of the sub form control that you brought in from the toolbox to contain the sub form
( IMPORTANT NOTE : If you use the wizard the sub form contol usually ends up with the same name as the sub form it contain. However, this need not be the case. )

.Form
I'm now refering to the Form properies of the form contained in the subform control - not the sub form control itself

!ControlName
The member of the sub form's Controls collection that you want to refer to


For properties( Like Allow Edits ) the final bit become .AllowEdits which, because of the .Form means the AllowEdits property of the sub form itself


EG.
Forms!FormName!subfrmcontrolName.Enabled = False
disables the entire subForm Control

Forms!FormName!subfrmcontrolName.Form!txtControl.Enabled = False
disables the txtControl on the subform




'ope-that-'elps.






G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
LittleSmudge,
Thanks for the information. I now understand.
My database does exactly what I want it to do..for now.
Thanks again.

PMO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top