I have Datasheet form with aim to only display records list. No additons, no edits, no delitions - thats done! But user still can change columns width, hide columns ... Is any way to dispose it?
While JBB's second suggestion is usually the way around the limitations of Datasheet View forms, I think his first suggestion is probably the one to go with here!
You probably should give your users the ability to hide columns they don't need, in a particular session, but return things to your intended display in subsequent sessions!
You can avoid them hiding a column by placing this in the Lost Focus event of each control
Code:
With CodeContextObject
Screen.ActiveControl.ColumnHidden = False
End With
Use it exactly as shown and put it into the Lost Focus event of each control which you don't want to be able to hide. You could set the width the same way.
I guess the column widths don't follow along. But regardless, you can keep them from being hidden and if they size it down small, it will still open with the column open on the next open.
Thanks!
This:
Forms![frmYourFormName]![YourFieldName].ColumnWidth = 100
and this:
With CodeContextObject
Screen.ActiveControl.ColumnHidden = False
End With
works. But I cant realize simly thing. I want that form On Load event sort one column to descending. How?
I tried but not work:
Forms![FormName]![FieldName].SortOrder = False
You probably should give your users the ability to hide columns they don't need, in a particular session, but return things to your intended display in subsequent sessions!
The only two ways a user can hide/unhide columns is by right-clicking on the selected column or doing it via the Format menu (pre Access 2007). So if you don't want them to be able to unhide a column then you should customise the menu bar and create your own context menus which excludes this Hide/Unhide Column option.
If you're going to use Bob's code then I would suggest this instead of using the CodeContextObject:
Code:
' Put it in a Module
Public Sub SetHideState(ctl As Control)
ctl.ColumnHidden = False
End Sub
' Call it like this, with or without the word Call.
Call SetHideState(Me.NameOfControl)