Show or hide columns in form on click

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
 
T

tina

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top