Is there an easy way, without using an error trap or looping through the name properties within the controls collection of a form, to determine whether a specific control has been defined on that form?
Not that I can think of... I suppose you might try and get at the form's property bag, but I seem to remember your having stated "an easy way"...
Thanks mmilan - I'm not a big fan of error traps and I always prefer to find an alternative even if it involves a few extra lines of code. Otherwise I just really wanted to know whether I was missing anything obvious. For example, Typename(NonExistentControl) returns Empty in immediate window but crashes in code - otherwise that might have been a nice option.
Private Function ControlExists(szName As String) As Boolean
On Error Resume Next
If Me.Controls(szName).Name<>"" Then ControlExists=True
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.