How to AutoFit Datasheet column width?

D

deko

Does Autofit only size columns to accommodate visible text? Can it size a
column to accommodate the appearance of a vertical scrollbar?

*** Here's the short version - code to prevent horizontal scrollbar from
appearing

If DCount("MyRecord","qrySubForm") > 6 Then
Screen.ActiveDataSheet.frmSubForm.ColumnWidth = 56
Else
Screen.ActiveDataSheet.frmSubForm.ColumnWidth = 60
End If

I think my syntax is screwed up here - and where would this code go?
Form_OnCurrent?

*** Here's the longer version:

I have a subform datasheet with one visible column. I need to keep the
column width fixed, regardless of what the visible text is. (The right
arrow key is used to view text that does not fit in the allotted width,
which is rare, but possible - real estate is scarce on this form.)

If I set the column width to 60, all is well until the number of records
displayed in the datasheet no longer fits within the height of the subform:
then a vertical scrollbar appears (if the height of the subform at 1 inch,
for example, that's about 6 records using standard row height of 11.25).

I want the vertical scrollbar, but *not* the horizontal scrollbar. The
horizontal scrollbar takes up space on the datasheet, hiding one or more
records at the bottom of the list.

I've set the subform's property sheet to allow vertical scrollbars only.
The problem is that the horizontal scrollbar *still appears* when the number
of records displayed in the datasheet exceeds the height of the subform,
causing the vertical scrollbar to appear. Apparently the vertical
scrollbar's appearance makes the datasheet think it needs a horizontal
scrollbar, especially when there is text in a row that the vertical
scrollbar covers up when it appears.

Can I use Autofit to accommodate the appearance of the vertical scrollbar?
Is there some other way to prevent the horizontal scrollbar from appearing
in this scenario?

I've thought about going to a continuous form, but I'm not sure that's going
to work.

suggestions very welcome!

Thanks!
 

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