Show or hide columns in form on click

  • Thread starter Thread starter Adam
  • Start date Start date
A

Adam

I'm have a mainform that directs the user to other form to input data, but
I'm not sure how to get one action button to only show x and y columns of
from Z and the other action button to only show columns A and B of form Z.
I'm guessing I need to use VBA to do this, but have no clue what commands
would accomlish this or if this can be done with a simple macro.

Thanks
 
assuming that the second form is in Datasheet view, rather than Single Form
or Continuous Forms view, you can set the ColumnHidden property in VBA, as

Me!ControlName.ColumnHidden = True ' hides the column
Me!ControlName.ColumnHidden = False ' shows the column

replace ControlName with the correct name of the control, of course. also,
the Me keyword assumes that the code is running in the module of the same
form that the control is in. if you're running the code in a separate form,
you'll need to use the full reference, as

Forms!FormName!ControlName.ColumnHidden = True

again, replacing FormName with the correct name of the form, of course.

hth
 
Back
Top