How to loop through all controls in a form, including controls in a subform - Access 2007 -


The title of my question tells how this is possible through all the controls in any form, including subfomes.

For example, I tag *

  Public Sub colCtrlReq (frame form) 'sets the background color for the required fields - & gt; Tag = * as dim controls set to set the string as the collar = RGB (255, 244, 164) DM CTL each CTL in frm.Controls If ctl.ControlType = acTextBox or ctl.ControlType = acComboBox or ctl. ControlType = acListBox then if InStr (1, CTL.TAG, "*") & lt; & Gt; 0 then ctl.BackColor = setColour End if End Is Next CTL set CTL = Nothing End Sub  

To Catch controls in a subform how it will change? Thanks in advance for any help or hints.

Cheers Noel

You can use Recursion

  public sub ColCtrlReq (Frame) "sets the background color for the required fields - & gt; tag = * dim set string as the collar = RGB (255, 244, 164) DM CTL for each CTL as a control, in the CRL, type CTL Control = ATtextbox or CTL. Control Type = ACCMOBOX _ or seat L. Control Type = Sielaistboks And if INSAT (1, CTL. Tag, "*") & lt; & gt; 0 then ctl.BackColor = setColour End if other CTL. Type Control = Siubform then colCtrlReq frm (ctl.Name ) .Form closing if next CTL set ctl = nothing end sub  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -