troubleshooting Question

Error 13 when checking Boolean statement

Avatar of TriMark
TriMarkFlag for United States of America asked on
VBAMicrosoft Access
15 Comments1 Solution184 ViewsLast Modified:
I have, what seems a very simple question. I have a string that I want to check the boolean but get a type mismatch error when  including a control variable.

Here is the code I'm using

Private Sub cmdAnalyze_Click()
   
   Dim ctl As Control
    For Each ctl In Me.reportSubForm.Controls
   
        If ctl.Name <> "_Label" Then
           If CBool("Me.[reportSubForm].Form.[" & ctl.Name & "].ColumnHidden") = False Then
             Debug.Print ctl.Name
             End If
        End If
Next


End Sub

It errors out on the line
 If CBool("Me.[reportSubForm].Form.[" & ctl.Name & "].ColumnHidden") = False Then

But this works
Private Sub cmdAnalyze_Click()
   
   Dim ctl As Control
    For Each ctl In Me.reportSubForm.Controls
   
        If ctl.Name <> "_Label" Then
             If Me.[reportSubForm].Form.[LastName].ColumnHidden = False Then
             Debug.Print ctl.Name
             End If
        End If
Next

I tried many things, but I am missing something simple.
Any help is appreciated!

Thanks Mark
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros