Datasheet & column widths

G

Guest

Is there a way to prevent users from adjusting column widths of a datasheet
form, either programatically or by a form property setting? Apparently this
isn't considered a design change. Setting the property sheet to allow design
changes only in design view doesn't affect this.
 
A

Allen Browne

Simple solution: use Continuous Form View instead of Datasheet. Users cannot
"lose" columns, hide them, freeze them, or get themselves into trouble.

As a bonus, you can display your form header/footer however you wish,
display totals, and include command buttons.

If you want to use Datasheets anyway, you can use Form_Open to configure
them the way they should be. Example:

Private Sub Form_Open(Cancel As Integer)
'Purpose: Set the column widths.

'Me.FrozenColumns = 0
Me.RowHeight = -1
With Me.ClientNum
.ColumnHidden = False
.ColumnOrder = 1
.ColumnWidth = 864
End With
With Me.Surname
.ColumnHidden = False
.ColumnOrder = 2
.ColumnWidth = 2880
End With

With Me.Address
.ColumnHidden = False
.ColumnOrder = 4
.ColumnWidth = -2 'Set for visible text.
End With

'Me.FrozenColumns = 2
RunCommand acCmdUnfreezeAllColumns
End Sub
 
S

Steve Schapel

Ctdak,

Only way I know of is not use datasheet. If you really like the look of
datasheet, you can format a continuous view form so it almost looks like
a datasheet.
 
G

Guest

Thanks for the input. I decided to stick with the datasheet view and use the
row and column setting statements you gave here in Form_Open. Users may need
to expand columns anyway, to see all the data in a field, so at least this
returns the display to "normal" each time the form is opened. Seems good
enough to me, and I don't care for continuous view.
ctdak
 
G

Guest

By the way, when I try to use the Me.FrozenColumns property setting I get
Run-time error 2135 - "This property is read-only and can't be set." What's
up with that?
ctdak
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top