johnmadigan
asked on
ms access hide datasheet column vba
I have a buttons on a main switchboard form. When I click a button it opens a form with a datasheet subform. When I click on a different button on the switchboard I want to open the same form with the same datasheet subform but hide a few colunms. So each different button will open the same form but different columns will be showing up in the subform.
What is the best way to handle this? I tried a few things on the click event of the button on the switchboard but could not get the subform to have some of the colums hiddend upon opening.
Any suggestions?
Thanks,
What is the best way to handle this? I tried a few things on the click event of the button on the switchboard but could not get the subform to have some of the colums hiddend upon opening.
Any suggestions?
Thanks,
I don't think it is possible to do what you want. Even if it is possible you are making life unnecessarily complicated for yourself.
Just create two forms ... each with the columns you want. (make a copy of your present one and edit it)
Just create two forms ... each with the columns you want. (make a copy of your present one and edit it)
If you do that, you'll end up with invalid columns on the sheet and they'll show the "#Name" value. With a Datasheet you can hide the columns as needed:
Me.YourControlName.ColumnH idden = True
Me.YourControlName.ColumnH
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So if button1 is clicked, you can set
button1 clicked : QueryDefs("qryData").SQL = "select a,b,c,d from tbl"
button2 clicked : QueryDefs("qryData").SQL = "select a,b,d from tbl"
button3 clicked : QueryDefs("qryData").SQL = "select c,d from tbl"
etc, where each click changes the columns being selected by the query behind the datasheet