I build a function to loop through all controls on a form and apply an event if it is a textbox/combobox/listbox, the function also test if the control is a subform and run the same function for the subform controls. The problem I have is if there is another subform in the subform I cannot loop through the controls.
Public Function FE_LoopThroughAllControlsNumLockOn(frm As Form)
Dim ctl As control
For Each ctl In frm
If ctl.ControlType = acSubform Then
Call FE_LoopThroughAllControlsNumLockOn(frm(ctl.Name).Form) 'Error here on subform within subform
ElseIf xIsControlForEventNumLock(ctl.ControlType) = True Then
ctl.OnGotFocus = "=FM_NUM_ON()"
End If
Next ctl
Set ctl = Nothing
End Function
Function xIsControlForEventNumLock(vControlType As AcControlType) As Boolean
Select Case vControlType
Case Is = acComboBox: xIsControlForEventNumLock = True
Case Is = acListBox: xIsControlForEventNumLock = True
Case Is = acTextBox: xIsControlForEventNumLock = True
Case Else: xIsControlForEventNumLock = False
End Select
End Function
If I try the following it works:
Debug.Print Forms!frmHR_Details!frm_HRDetails2.Form!HRSubForm2.Form!sID
But this does not, Why?
Debug.Print Forms("frmHR_Details").Form("frm_HRDetails2").Form.Form("HRSubForm2").Form.sID.Value
Or is there maybe not a way to do this:
set ctl = Eval("Forms!frmHR_Details!frm_HRDetails2.Form!HRSubForm2.Form!sID")
frm(ctl.Name).Form, tryctl.Form. - Andre