I have a piece of code which uses For Each Control to loop through a piece of code for each control on my form.
However, I want to be able to limit it to certain controls on the form now.
Worst comes to worst I'll stick the code in a module and pass the control name to the function but I'd rather do this without having to do major work on the code.
I had been trying code like this but it looks like .ControlName doesn't do what I had hopes when used on a control object (which is what ctl is in the following code):
Anyone have any suggestions? This is access 97 by the way (don't even start about how outdated that is... not my decision).
However, I want to be able to limit it to certain controls on the form now.
Worst comes to worst I'll stick the code in a module and pass the control name to the function but I'd rather do this without having to do major work on the code.
I had been trying code like this but it looks like .ControlName doesn't do what I had hopes when used on a control object (which is what ctl is in the following code):
Code:
Dim ctl as Control
For Each ctl in Me.Controls
If ctl.ControlName = "NameOFirstControlToWork" or ctl.ControlName = "NameOfSecondControlToWork" Then
'Code to run
End If
Next Ctl
Anyone have any suggestions? This is access 97 by the way (don't even start about how outdated that is... not my decision).