For Each SubForm in Form

  • Thread starter Thread starter Mus' via AccessMonster.com
  • Start date Start date
M

Mus' via AccessMonster.com

Having a bad day at the office.......

I'm trying to implement a simple procedure set the
AllowAdditions/Edits/Deletions on a form and all of its subforms.

I'm trying allong the lines of:


For Each SubForm in Forms!frmTest
AllowAdditions = False
AllowEdits = False
AllowDeletions = False

Next

However, when debug.printing this seems to list all of the controls in the
form?

Any assistance for appreciated ....It's been a long day (suspect database
corruption (search key not found) and the above properties seems to have
reset themselves randomly?).....
 
To my knowledge a subform is considered a control just like everything
else. In order to differentiate if a control is a subform or not, you'd
have to look at certain properties such as SourceObject,
LinkMasterFields and LinkChildFields.
 
Mus' via AccessMonster.com said:
Having a bad day at the office.......

I'm trying to implement a simple procedure set the
AllowAdditions/Edits/Deletions on a form and all of its subforms.

I'm trying allong the lines of:


For Each SubForm in Forms!frmTest
AllowAdditions = False
AllowEdits = False
AllowDeletions = False

Next

However, when debug.printing this seems to list all of the controls
in the form?

Any assistance for appreciated ....It's been a long day (suspect
database corruption (search key not found) and the above properties
seems to have reset themselves randomly?).....

The subforms are held in subform controls. You could use code along the
lines of

Dim ctl As Access.Control

For Each ctl in Forms!Test.Controls

If ctl.ControlType = acSubform Then
With ctl.Form
.AllowEdits = False
.AllowAdditions = False
.AllowDeletions = False
End With
End If

Next ctl

That only handles one level of subform, though. If you have nested
subforms, it's going to get more complicated.
 
Thanks Guys, my brain has finished for the day. The corruption has lost me a
full day but at least this makes my day (evening) a little easier.

:o)
 
Back
Top