I just want to hide a column in a subform

jbrandes

New Member
Joined
Dec 20, 2011
Messages
10
I'm tring to toggle the visible property of a column in a sub form based on input from a check box on the main unbound form

If Me.Check55 = True Then

'This part works fine, if checkbox 55 is true the subform filters records based on "DBSUB.[Austin] Yes or No

strWhere = strWhere & " AND " & "DBSUB.[Austin] = " & Me.Check55

'These are just a few of my attempts to hide other columns that are not needed

Me!DBSUB.Dallas.ColumnHidden = True
'Forms!DBSUB.Controls!Dallas.Visible = False
'Forms!DBSUB.Dallas.Visible = False
'Me!DBSUB(Dallas).Visible = False

'None of these work, please any suggestions?


End If
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Sorry, yes the subform is a datasheet. I can hide any column I wish manually, I just can seem to do with the code.

Thanks.
 
Upvote 0
I'm pretty sure you can't do it with code.

Why do you want to hide the 'column' anyway?
 
Upvote 0
The columns I want to hide are just not pertinent to the results that are displayed, Plus it make the datasheet to wide. There are acually several columns that I will be hiding based on user selections, but if I can get one to work I can get them all.

There has to be some way to make them not seen, setting the column width to 0 or something, anything.

Thanks
 
Upvote 0
If you right click on the columns you want to hide in datasheet view, you will be given an option to hide the column.

Alan
 
Upvote 0
Yep, I know I can do it manually, but I would like the code to handle it based on a user selection from the main form.

If this (Mainform) checkbox is checked hide that (Subform)column... Seems simple I don't know why I can't figure it out.

Thanks
 
Upvote 0
jbrandes

As far as I know it's just not possible.

If the column(s) aren't relevant why are they shown in the datasheet anyway.
 
Upvote 0
jbrandes

As far as I know it's just not possible.

SURPRISE! Actually, it is possible.

Here's a nice article on what you can do with Datasheets:
http://msdn.microsoft.com/en-us/library/aa217449(office.11).aspx

And the property that should be used is

ColumnHidden

So, if this didn't work:

Me!DBSUB.Dallas.ColumnHidden = False

then the problem may be

1. Referring to the subform instead of the subform CONTROL which is what should be used.

2. Referring to the FIELD instead of the CONTROL which should be used.


@jbrandes - For Subforms you must refer to the subform control (control on the subform which HOUSES the subform on the parent form) and NOT the subform name itself UNLESS the subform control and the subform are named the EXACT same.

So,

Me.SubformControlNameHere.Form.TextBoxNameHere.ColumnHidden = True

would be the correct syntax.
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,795
Members
449,048
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top