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
 
Bob

I think I kind of knew, but wasn't sure.

Seeing that article brings it all flooding back.

Might give it a go later.:)
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
I think that's a little closer however it still errors out stating...
"You have entered an expression that has an invalid reference to the property Form/Report"

And yes the control and the form name are both DBSUB

If Me.Check55 = True Then

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

Me.DBSUB.Form.Dallas.ColumnHidden = True

End If

Thanks I really appreciate the help.
 
Upvote 0
I think that's a little closer however it still errors out stating...
"You have entered an expression that has an invalid reference to the property Form/Report"

And yes the control and the form name are both DBSUB

If Me.Check55 = True Then

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

Me.DBSUB.Form.Dallas.ColumnHidden = True

End If

Thanks I really appreciate the help.

It would appear that the subform control on your main form is NOT named DBSUB and/OR the text box is named the same as the field and so it needs to be renamed to txtDallas or something.

If you aren't sure how to tell what the subform control's name is, take a look at the screenshot here:
http://www.btabdevelopment.com/ts/ewtrhtrts
on my "quick tutorial" about subforms.
 
Upvote 0
I currently have the subform on the main forms footer, does it make a difference?

I would send you a screen shot but I have no place to put it right now.
 
Upvote 0
Wow, I'm just missing something, I've gone over everything with no luck.

I just need to let it go for awhile and come back to it fresh latter.

Thanks for all you help Bob I really appreciate it.
 
Upvote 0
Wow, I'm just missing something, I've gone over everything with no luck.

I just need to let it go for awhile and come back to it fresh latter.

Thanks for all you help Bob I really appreciate it.

When you want to try some more, answer these questions:

1. What is the name of the subform itself?

2. What is the name of the Subform Control?

3. What is the name of the field in question?

4. What is the name of the text box bound to the field?
 
Upvote 0
I think I got it, To start off the formfooter and therfore the subform is not visible and the last thing I do is make it visible with this...

If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If


So I moved this bit of code to the top after the variable are declared and all seem well.
 
Upvote 0
Just out of curiosity, can I ask why you want to hide column(s) anyway?

Are the columns you want to hide just being used for filtering?

If they are it could be possible not to display them right from the start.
 
Upvote 0
I have a database of subcontractors that do work for us in various cities around the southwest. In this database (which I did not design by the way) there are yes/no columns for each of the subs if they do work in that city. We have designed a main form that is used to add / delete records for that database and has checkboxes that we can select for the cities that they will work in. All well and good. Now I want to design an easy way for anybody to search those records (even those that know zip about access). Viola no problem, I'll design a search form that among other things the user can select with a checkbox which city they need and they will be presented with a list view of all of the subs that work in that city. However I don't really want to show all of the columns of the cities that they do not work in.



Now I'm sure that there is probably a much better more elegant way to accomplish this task, but I was already a long way down this road when I hit this problem and didn't really want to rethink the logic behind it all.

It ain't pretty but it seems to work.

Thanks for all the help I'm sure that without it I would have been here awhile.

Jim
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

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