Yes I do, thank you.
The parent form is 'Candidates' for registration etc and suitability,
if the 'Suitable' check box isn't ticked, I want the subform to be
dormant so to speak. If it is ticked then I want it to be 'enabled' to
be completed. I would really prefer it to seem greyed until the
suitable check box in the Candidates form is ticked.
I'm ready for instructions!!
Okay. As I mentioned before, you're going to have to pick one control
on the subform to receive the focus while the others are disabled. This
control cannot be disabled.
Here's code for a function you can put into a standard module:
'------ start of code for standard module ------
Public Function fncEnableDisableControls( _
frm As Form, _
EnableIt As Boolean, _
FocusControl As String)
' Enable or disable all data-bound controls on form <frm>,
' depending on the value of <EnableIt>: True = Enable; False =
Disable.
On Error GoTo Err_fncEnabledisableControls
Const conERR_NO_PROPERTY = 438
Dim ctl As Control
If EnableIt = False Then
frm.Controls(FocusControl).SetFocus
End If
For Each ctl In frm.Controls
If ctl.Name <> FocusControl Then
ctl.Enabled = EnableIt
End If
Skip_Control: ' come here from error if no .Enabled property
Next ctl
Exit_fncEnabledisableControls:
Exit Function
Err_fncEnabledisableControls:
If Err.Number = conERR_NO_PROPERTY Then
Resume Skip_Control
Else
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Exit_fncEnabledisableControls
End If
End Function
'------ end of code for standard module ------
Now, in the main form's module you'll need to call this function from
two places: the form's Current event and the AfterUpdate event of the
[Suitable] check box. Suppose that your subform is named
"sfSuitability", and the control on that form that you want to hold the
focus when disabling other control is called "ID". (Of course, you'll
need to amend these names in the code below.) Then your code for the
main form's module would be something like this:
'------ start of code for form module ------
Private Sub Form_Current()
fncEnableDisableControls Me!sfSuitability.Form, Me.Suitable, "ID"
End Sub
Private Sub Suitable_AfterUpdate()
fncEnableDisableControls Me!sfSuitability.Form, Me.Suitable, "ID"
End Sub
'------ end of code for form module ------
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)