Link to home
Start Free TrialLog in
Avatar of Karen Schaefer
Karen SchaeferFlag for United States of America

asked on

ColumnHidden stopped working

I have code that was working great then without change it stopped working.  I have a subform that has a datasheet view and I only want those columns that are applicable to the selected record to be visible.

See my current code - the AP1.ColumnHidden = True, all of the sudden the .columnhidden will not compile - Access does not recognize the .columnhidden.

The code is ran after an crosstab query is run and sets the column values to AP1, AP2, etc.
Then suppose tho check the value of that column to determine if it is applicable or not.

I am getting the following error:  "Compile Error:  Member or data member not Found"


Any ideas why?

k
Private Sub Form_Current()
Dim nTBL As String
   On Error GoTo Form_Current_Error
 
    nTBL = "tblFTIR_Temp"
    If Nz(DSum("[AP1]", nTBL), 0) <= 1 Then
        AP1.ColumnHidden = True
    Else
        AP1.ColumnHidden = False
    End If
    If Nz(DSum("[AP2]", nTBL), 0) <= 1 Then
        AP2.ColumnHidden = True
    Else
        AP2.ColumnHidden = False
    End If
    If Nz(DSum("[AP3]", nTBL), 0) <= 1 Then
        AP3.ColumnHidden = True
    Else
        AP3.ColumnHidden = False
    End If
    If Nz(DSum("[AP4]", nTBL), 0) <= 1 Then
        AP4.ColumnHidden = True
    Else
        AP4.ColumnHidden = False
    End If
    If Nz(DSum("[AP5]", nTBL), 0) <= 1 Then
        AP5.ColumnHidden = True
    Else
        AP5.ColumnHidden = False
    End If
    If Nz(DSum("[AP6]", nTBL), 0) <= 1 Then
        AP6.ColumnHidden = True
    Else
        AP6.ColumnHidden = False
    End If
    If Nz(DSum("[AP7]", nTBL), 0) <= 1 Then
        AP7.ColumnHidden = True
    Else
        AP7.ColumnHidden = False
    End If
    If Nz(DSum("[AP8]", nTBL), 0) <= 1 Then
        AP8.ColumnHidden = True
    Else
        AP8.ColumnHidden = False
    End If
    If Nz(DSum("[AP9]", nTBL), 0) <= 1 Then
        AP9.ColumnHidden = True
    Else
        AP9.ColumnHidden = False
    End If
    If Nz(DSum("[AP10]", nTBL), 0) <= 1 Then
        AP10.ColumnHidden = True
    Else
        AP10.ColumnHidden = False
    End If
End Sub

Open in new window

Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

On which line does this error occur?
Avatar of Karen Schaefer

ASKER

the first instance of '<<<<<<<<
    nTBL = "tblFTIR_Temp"
    If Nz(DSum("[AP1]", nTBL), 0) <= 1 Then
        AP1.ColumnHidden = True"<<<<<<<<<
    Else
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What else could it be, because the names of the fields have not changed?

K
The strange thing is that the code still works correctly but when I try to compile the mdb I have an issue.
k