Home > other >  Hide/Show Columns in MS Access Query using a Checkbox
Hide/Show Columns in MS Access Query using a Checkbox

Time:12-28

I am using MS Access 2016 and building a form to run a query that enables users to only extract columns that they need. I am planning on doing this with a checkbox for every column. How can I do this? I have tried the following but it does not work. It gives me a Compile Error: Method or data member not found.

Private Sub chk1_AfterUpdate()
  Me.column4.Visible = Nz(Me.chk1 = True, False)
End Sub

Private Sub Form_Current()
  Me.column4.Visible = Nz(Me.chk1 = True, False)
End Sub

CodePudding user response:

You can hide a control but not a field. So try, where TextBox4 is bound to your column4:

Private Sub chk1_AfterUpdate()
    Me!TextBox4.Visible = Nz(Me!chk1.Value, False)
End Sub

Private Sub Form_Current()
    Me!TextBox4.Visible = Nz(Me!chk1.Value, False)
End Sub

CodePudding user response:

  Private Sub Check20_Click()
         If Me.Check20.Value = -1 Then
         Me.ID.Visible = False
         Else
         Me.ID.Visible = True
         End If
   End Sub

i will advise you to be careful placing any code under the form_current event, because it might be tricky to implement, this approach

  • Related