Joe
Joe

Reputation: 626

Prevent User From Unhiding Datasheet Columns

I have hidden several columns in an access datasheet using the ColumnHidden property like this example here:

ColumnName.ColumnHidden = true

This works great, but when I view the datasheet, the end user can unhide the column by "resizing" the space either side of where the column is hiding:

enter image description here

I have found a couple of hacks to resize the columns using the ColumnWidth property via vba on certain events vba etc. but I was wondering whether there is a simple way to disable this "resize" feature in the first place for hidden columns only?

Upvotes: 1

Views: 1076

Answers (1)

Sergey S.
Sergey S.

Reputation: 6336

In MouseUp event You can check if ColumnHidden of hidden column is false (user "resized" the column), hide it.

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Me.MyHiddenColumn.ColumnHidden = False Then
    Me.MyHiddenColumn.ColumnHidden = True
End If
End Sub

Upvotes: 3

Related Questions