For Each SubForm in Form

  • Thread starter Mus' via AccessMonster.com
  • 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?).....
 
D

David C. Holley

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.
 
D

Dirk Goldgar

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.
 
M

Mus' via AccessMonster.com

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.

:eek:)
 

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