Column widths in a datasheet form view

D

Dale Fye

I'm working on a form for a client who wants the data to be presented in a
datasheet view (AllowEdits = False). Basically, this datasheet is actually
a subform on another form, but that is generally immaterial.

What I would like to do is when the form opens, programmatically set the
widths of several of the fields in the subform. I know that the user can
reset these widths at a later time, but I want to start out having them a
specific width. Is there a way to do this in Access 2K?

The reason I am using a datasheet and not a listbox is that columns can be
rearrranged, resized, hidden, filtered, sorted, searched, etc in the
datasheet view, but this is a little more difficult in a listbox. This
functionality gives the various users a little more flexability in the way
they organize the data.
 
D

Dirk Goldgar

Dale Fye said:
I'm working on a form for a client who wants the data to be presented
in a datasheet view (AllowEdits = False). Basically, this datasheet
is actually a subform on another form, but that is generally
immaterial.

What I would like to do is when the form opens, programmatically set
the widths of several of the fields in the subform. I know that the
user can reset these widths at a later time, but I want to start out
having them a specific width. Is there a way to do this in Access 2K?

The reason I am using a datasheet and not a listbox is that columns
can be rearrranged, resized, hidden, filtered, sorted, searched, etc
in the datasheet view, but this is a little more difficult in a
listbox. This functionality gives the various users a little more
flexability in the way they organize the data.

Yes, you can do it by setting the ColumnWidth property of each bound
control to a value in twips (1/1440 inch). For example:

'----- start of example code -----
Private Sub Form_Open(Cancel As Integer)

Me!ID.ColumnWidth = 1440 ' 1 inch
Me!Desc.ColumnWidth = 2880 ' 2 inches

End Sub

'----- end of example code -----

I assume this will work on a subform, though I only tried it on a main
form.
 
G

Guest

Dirk,

Seems awfully simple. I had tried setting the column widths in design view,
and that didn't work, so I just assumed it would not be this easy.

Thanks, again

Dale
 

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