UniqueData
asked on
Hide column in datasheet view
I recently posted a question which I thought was answered, but I am having an issue.
Here is the previous question:
https://www.experts-exchange.com/questions/22128522/Change-datasheet-source-dynamically.html
I thougth it worked until I had a table that had 3 fields. The first field (ID field) was hidden correctly, the second showed fine, but the third column was hidden.
Thanks in advance,
Michael
Here is the previous question:
https://www.experts-exchange.com/questions/22128522/Change-datasheet-source-dynamically.html
I thougth it worked until I had a table that had 3 fields. The first field (ID field) was hidden correctly, the second showed fine, but the third column was hidden.
Thanks in advance,
Michael
ASKER
I want this to be done with code. It looks like the code is suppose to show all columns and hide the unused columns, but it doesn't seem to work.
By what criteria do you determine if a column should be hidden?
UD,
Because you're dealing with a form, and this form has fixed controls, you literally have to make any unused controls invisible for them not to show up on a datasheet view.
J
Because you're dealing with a form, and this form has fixed controls, you literally have to make any unused controls invisible for them not to show up on a datasheet view.
J
Alas, setting a control as not visible doesn't change it's appearance in datasheet view.
Setting the Columnwidth = 0 hides it (but it's still there - able to be dragged out again :-( )
(A column resize event would be a handy thing of course to combat this - click is the only event that is of any use... but not much here).
Ultimately it's still just a question of determining which columns you want to hide though.
Setting the Columnwidth = 0 hides it (but it's still there - able to be dragged out again :-( )
(A column resize event would be a handy thing of course to combat this - click is the only event that is of any use... but not much here).
Ultimately it's still just a question of determining which columns you want to hide though.
>>>Alas, setting a control as not visible doesn't change it's appearance in datasheet view.
Right so....Thx Leigh
Right so....Thx Leigh
ASKER
I don't mind that they can drag out the column (of course I wish there was a way to completely get rid of the columns not needed).
As far as the criteria for which columns to show...
The solution that my previous question has is to have 5 text boxes. I never want to see the first field of the table. I always want to see the other columns. So what the code is suppose to do is assign field 2 to textbox 1, field 3 to textbox 2, etc. Of course this sample only works for tables with no more than 6 fields (including the ID field) but thats not a problem and I can always add more text boxes. Then the text boxes that are not needed (because there are not that many fields in the table) should be 'hidden'.
I experimented with what was going on and here is what I found. Most of my tables consist of two fields (including the ID field). One of them has three fields. When I have a table loaded that has two fields, only text box 1 was visible and I manually stretched out text box 2. Then I switched the source to the table that has three fields. The data showed up perfectly. Then I switched back to the table with 2 fields. It did the correct thing of hiding text box 2. But when I switched to the table with three fields, text box did not automatically resize to visible. So in summary, the text box would keep its size if it was there already, but if the size gets changed to zero it does not go back to visible when needed.
Steve, are you out there??
As far as the criteria for which columns to show...
The solution that my previous question has is to have 5 text boxes. I never want to see the first field of the table. I always want to see the other columns. So what the code is suppose to do is assign field 2 to textbox 1, field 3 to textbox 2, etc. Of course this sample only works for tables with no more than 6 fields (including the ID field) but thats not a problem and I can always add more text boxes. Then the text boxes that are not needed (because there are not that many fields in the table) should be 'hidden'.
I experimented with what was going on and here is what I found. Most of my tables consist of two fields (including the ID field). One of them has three fields. When I have a table loaded that has two fields, only text box 1 was visible and I manually stretched out text box 2. Then I switched the source to the table that has three fields. The data showed up perfectly. Then I switched back to the table with 2 fields. It did the correct thing of hiding text box 2. But when I switched to the table with three fields, text box did not automatically resize to visible. So in summary, the text box would keep its size if it was there already, but if the size gets changed to zero it does not go back to visible when needed.
Steve, are you out there??
ASKER
AAAHHHHHHH. I found it...
Steve had a line
txt.ColumnWidth = (intLoop <> 1)
It should have been
txt.ColumnHidden = (intLoop = 1)
That took care of everything.
Thanks all for trying.
Steve had a line
txt.ColumnWidth = (intLoop <> 1)
It should have been
txt.ColumnHidden = (intLoop = 1)
That took care of everything.
Thanks all for trying.
lol I hadn't tried yet really. I was still waiting to find out what critieria you were using to determine omission :-p
hmmm ... as long as it works for you :-)
my original though was to set the column width to 0 (false) if was column 1 and set column width to -1 (default size) if not. Apparently default size (whatever that really means :-)) is overwritten if the column ever had a custom size during the session, which, switching back and forth does create a custom setting :-) nice catch !!!
my original though was to set the column width to 0 (false) if was column 1 and set column width to -1 (default size) if not. Apparently default size (whatever that really means :-)) is overwritten if the column ever had a custom size during the session, which, switching back and forth does create a custom setting :-) nice catch !!!
ASKER
I hear that the new version of Access has a way to display a totals 'footer' in datasheet view. I wonder if they made it possible to actually hide columns!!???
ASKER
So since I figured out the issue, what do I do? I don't see an option to delete the question
open a Q in community support (Support link on very top right of this page) asking them to PAQ and refund, please include a link to this Q for them.
Steve
Steve
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
J