Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide columns/controls on a query/form programatically 1

Status
Not open for further replies.

storm75m

Programmer
Apr 18, 2001
81
0
0
US
I have a form that displays it's data in Datasheet view. When I try to set one of the control's visible properties to false (me.txtAddress.Visible = False), it still shows the column in datasheet view. However I notice that if I remove the control completely that it doesn't show the column. How can I hide this column programatically?

What I'm trying to accomplish is giving the user the ability to show or hide certain fields of a query by using a form. I have a form named rptCriteria with a checkbox for each field in the query. The query is bound to a form named frmRecords that opens in datasheet view (I want the users to see a datasheet so they can sort and easily export to Excel, etc.) I thought I could hide and show the fields by simply setting the visible property of each field to the value of the check box on the rptCriteria form:

Me.controlname.visible = [forms]![rptCriteria]![fldCheck].value

But apparently, even if I set the visible property manually, the column is still displayed. Maybe there is an easier way to accomplish this? I'm trying my best not to have to programatically generate the Recordsource SQL string, which could be a nightmare. Thanks for any help you can provide!!
 
In datasheet view you need to replace

Me.txtAddress.Visible = False

with

Me.txtOwnStars.ColumnHidden = True


TomCologne
 
In datasheet view you need to replace

Me.txtAddress.Visible = False

with

Me.txtAddress.ColumnHidden = True


TomCologne
 
This command will hide the column in datasheet view. However, the user can still unhide it. If you don't want the user to ever see it, then you will need to remove its ControlSource and reassign it when you need it. Anyway, here's the code:

YourControlName.ColumnHidden = true
 
Thanks, looks like that will work. However, how can I reverse the value of a check box, so that i can set the property on one single line?

me.txtAddress.ColumnHidden = [Forms]![frmCriteria]![ckAddress].value

This will no longer work, it will do the exact opposite of what I need...
 
me.txtAddress.ColumnHidden = Not [Forms]![frmCriteria]![ckAddress].value


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top