This works wonderfully but now I've got two subforms. I need the new subform to disable when the form controls are disabled and enable when the form controls are enabled. But I'm not sure how to refer to one subform.
Here is the code on the form that disables form controls and enables the subform:
Private Sub btnNewReplicate _Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acSubform Or ctl.Name = "btnNewReplicat e" Then
ctl.Enabled = True
Else
If ctl.ControlType <> acLabel Then
ctl.Enabled = False
End If
End If
Next
End Sub[/code]
And here is the code on the subform that enables the form controls and disables the subform:
Expand|Select|Wrap|Line Numbers
- Private Sub btnNewSurvey_Click() 'New Survey button - enable form, disable subform
- Dim ctl As Control
- For Each ctl In Me.Parent.Controls
- If ctl.ControlType <> acLabel And Not ctl.ControlType = acSubform Then
- ctl.Enabled = True
- ctl.SetFocus
- ElseIf ctl.ControlType = acSubform Then
- ctl.Enabled = False
- End If
- Next
- DoCmd.GoToRecord acDataForm, "frm_Survey", acNewRec
- DoCmd.GoToControl "txt_SurveyNum"
- End Sub
Expand|Select|Wrap|Line Numbers
- If ctl.ControlType = acSubform