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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms/Subform Properties 1

Status
Not open for further replies.

Mudshark

Programmer
Sep 26, 2000
11
0
0
US
This has me stumped...Would appreciate any light for a fellow Prog..

1. I have a button the main form which set the main form's proterties (AllowEdits, AllowDeletions, AllowAdditions) to TRUE so the user can modify the data

2. However, this doesn't set the subform's properties so they can

3. I tried:
Forms![Master3]![PhoneSub].AllowEdits = True
with "Master3" for main form and "PhoneSub" the subform but that gives me the following error:

Run-time error '438'
Object doesn't support this property or method

How can I give the user the ability to modify both the forms and their underlying subforms with code from a button on the main form

thanks for your time



 
Do your sub-forms start off open. If not, then you can set a variable, and as they activate, if the variable has been set by your button, then they can allowedits = true.

If they are starting off open, then it may be an idea to close, and then open them without the user noticing, except for the flicker.

Private Sub Form_Activate... whatever

If variable = 1 then
formwhatever.allowedits = true
variable = 0
end if

end sub

It's just an idea
 
The main forms start off as read-only (no editing/modifications in the properties)

the button (which will even be password if/then/elsed) will set the forms and it's subforms to modification status (which is what I can't seem to do because the button is located on the main form and I can't see to access the subform's property values from the main form)
 
Hi there,

I just noticed this post in a search, as I was looking for an answer to a related problem.

The work-around I have found is:

Private Sub EditRecord_Click()

Forms!frmMain.AllowEdits = True

Forms!frmMain!subfrmCourseData.SetFocus
Me.AllowEdits = True

End Sub

The master form (frmMain) has it's AllowEdits property set to False in a Load event. When the user clicks the EditRecord button the AllowEdits property is set to true, and then the focus is moved to the sub form (sbfmCourseData). Once the focus is there the sub form behaves like any other form, so it's AllowEdits property can be set to True.

I hope this helps, or at least gives you some other ideas!

Cheers,
Cja
 
the way I do it is like that:

[tt]
If Me.OpenArgs = "edit" Then

Me.AllowAdditions = True
Me.AllowEdits = True
For Each myControl In Controls
Select Case myControl.ControlType
Case acSubform
myControl.Form.AllowAdditions = True
myControl.Form.AllowEdits = True
End Select
Next
Else
Me.AllowAdditions = False
Me.AllowEdits = False
End If[/tt]

well my situation is different since the button is in another form but beside that it should work perfectly
the advantage of my code is that you don't need to enter the form/subforms name and you can add/remove subforms within the form without having to change that part of the code...code it and forget it!(just like the chicken in the ads).

there's surely some bad points to my code but like a good politician, I won't mention them



jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.
 
That's a much better way to do it.

You might want to think about putting your answer into an FAQ as quite a lot of people have the same question.

Have a good weekend!
 
It's really a lot simpler than all that. The deal is, if you want to refer to one of the methods or properties of a subform, you have to insert ".Form" immediately after the reference to the subform, otherwise, you're refering to a method or property of the _subform control_, not the subform itself.

Forms![Master3]![PhoneSub].whatever

refers to a method or property of the subform control.

Forms![Master3]![PhoneSub].Form.whatever

refers to a method or property of the subform.

Forms![Master3]![PhoneSub].Form.AllowEdits = True

should do the trick for you.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top