Forum Discussion
Tony2021
Dec 31, 2021Steel Contributor
ColumnHidden Property - Doesnt seem to hide
Hello, is the below the correct code to turn on/off the columnhidden in a datasheet? Me.txtProjName2.ColumnHidden = True Me.txtProjName2.ColumnHidden = False I have opened the form and rig...
George_Hepworth
Jan 01, 2022Silver Contributor
You could experiment a bit with the syntax (one of the best trouble-shooting methods I know), although I did miss cleaning that up when I redacted the full procedure to remove some unnecessary elements for this example. The name of the label is exitProc:, not Cleanup
Tony2021
Jan 01, 2022Steel Contributor
Hi George. Thank you for the correction. Question: Is the code suppose to hide certain fields or applies to all fields that are hidden (rt clicked field and chose hide).
I need to hide only 1 field on my split form. I think I am doing something wrong but from what I have read all you do is make a button and put the below code on it. I thought maybe my form was corrupted and I created another form and put 2 buttons on it (1 for hide, 1 for unhide) with the code but nothing happens. The field doesnt hide or unhide even after I manually assign it as hidden by rt click thinking its something to do with the initial setting when form opens.
What do you think I am doing wrong? The below code seems simple enough so I narrow it down to how I am using it or there is something missing. Can you create a form and hide unhide with the below code?
Private Sub txthide_Click()
Me.txtProjectName.ColumnHidden = True
End Sub
Private Sub txtUnhide_Click()
Me.txtProjectName.ColumnHidden = False
End Sub
- George_HepworthJan 01, 2022Silver Contributor
Tony2021 It should impact only controls with one of the two tags specified. (The tag has to match exactly.)
By the way, I also seem to have misinterpreted the original question. You specified a datasheet in the original question.
However, in this answer you mention a split form, in which there is both a datasheet section and a "normal" section. I must have missed that before.
I am not sure that I've ever tried something like this in a split form. I'm sure it would not impact the normal view section of the form, even if it does work with the datasheet section.... More testing required.
- Tony2021Jan 01, 2022Steel ContributorGeorge, I have found the answer. The previously posted codes do not work on a split form. Only the below works for a split form. I searched quite a bit online. Many websites do not state that a split form requires different codes. Anyways, I am using the below and it works great. thank you for the assistance. I can use the other codes on another form to auto fit the fields.
Private Sub txthide_Click()
'Me.txtProjectName.ColumnHidden = True 'this doesnt work on a split form
Screen.ActiveDatasheet.txtProjectName.ColumnHidden = True
End Sub
Private Sub txtUnhide_Click()
'Me.txtProjectName.ColumnHidden = False 'this doesnt work on a split form
Screen.ActiveDatasheet.txtProjectName.ColumnHidden = False
End Sub- George_HepworthJan 01, 2022Silver ContributorI'm glad to hear you worked it out. Continued success with the project.