Share via

VBA How to hide or show Columns in ms Access

Anonymous
2020-10-21T18:02:17+00:00

Hi I'm Steffen

  • I have a question that I can't figure out myself.
  • I have developed a database in MS Access.
  • I would like it to be made that way that if I press the Yes/No button, the columns are either displayed or saved.

Is it possible to do that

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2020-10-22T04:18:44+00:00

Hi Steffen,

Try the following in the onclick or after update event of your check box:

If Me.CheckBoxName = True Then

[Forms]![MainFormName]![SubFormName]![FieldName].ColumnHidden = True

Else

[Forms]![MainFormName]![SubFormName]![FieldName].ColumnHidden = False

End If

Replace the bolded names with your own.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Anonymous
    2020-10-22T12:23:31+00:00

    Hi :)

    Thanks a lot for your answer. I was the answer I looking for

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2020-10-22T12:07:48+00:00

    I just didn't know the code Tom.  I think the post by Steffen should have said displayed or hidden.  Perhaps an error using the word saved.  Thanks Tom

    Was this answer helpful?

    0 comments No comments
  3. Tom van Stiphout 40,201 Reputation points MVP Volunteer Moderator
    2020-10-22T03:14:53+00:00

    >the columns are either displayed or saved.

    Did you mean: either displayed or not displayed?

    If so, code like this may work:

    Me.mysubformname.Form.mycontrol.ColumnWidth = iif(me.myCheckbox, 1000. 0)

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2020-10-21T23:33:29+00:00

    Hi,  I'm not sure about a button and the code. but you can Freeze fields.   Select the fields by pressing Shift and the fields you want frozen.  Right Click and choose Freeze Fields.  You can save these settings when you save the database or you can Right Click and choose Unfreeze.

    This might not be what you wanted, but it may help.

    Rob

    Was this answer helpful?

    0 comments No comments