Lock datasheet form

Osix

Registered User.
Local time
Today, 21:10
Joined
Feb 3, 2011
Messages
19
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?
 
I don't believe that there is any way to prevent the user adjusting the column width in Datasheet view.

You could however use;
Code:
Forms![frmYourFormName]![YourFieldName].ColumnWidth = 100
In the Form's On Load event to return the column width to your default settings
 
Alternatively set up a continuous form to replicate the look you are after.
 
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!

Linq ;0)>
 
I don't believe that there is any way to prevent the user adjusting the column width in Datasheet view.

You could however use;
Code:
Forms![frmYourFormName]![YourFieldName].ColumnWidth = 100

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
 
I got it
Me.OrderBy = "Inventars DESC"
 
Intresting, but boblarsons code sometimes work and sometimes not!?!

With CodeContextObject
Screen.ActiveControl.ColumnHidden = False
End With

I try to hide column more than one time and sometimes column hides.
Obscurity
 
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!

Linq ;0)>
Following what Linq mentioned, I would do something like what this poster did in post #3 (i.e. image attached):

http://www.access-programmers.co.uk/forums/showthread.php?t=205660

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)
 

Users who are viewing this thread

Back
Top Bottom