Can't Hide Datasheet Column

TastyWheat

Registered User.
Local time
Today, 07:19
Joined
Dec 14, 2005
Messages
125
I have a subform in datasheet view and I wish to selectively hide columns I'm not using (depending on the query). I wrote a small function to make it easier. Here's my code:
Code:
Function HideColumn(myForm As SubForm, myLabel As String)
    myForm.SetFocus
    myForm.Controls(myLabel).SetFocus
    DoCmd.RunCommand acCmdHideColumns
End Function
So all I do is send the subform name while I'm using the parent form and then give it the column name to hide. Oddly enough this code works for columns such as "Net B" and "Net% +/-", but it doesn't work with the columns "Period B" or "Period A". On my subform the text boxes and their labels have the same name (if that even matters). I keep getting a 2465 error (field not found) no matter what I change the column name to.
 
Never fails that I answer my own question.

The control source and the text box itself had different names for "Period A" and "Period B". For everything else they were the same so I was under the impression I had to give the name of the control source or even the label.
 

Users who are viewing this thread

Back
Top Bottom