By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 2,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

Datasheet Subform - Change the width of a column

P: n/a
I have a subform that displays a datasheet. There are a couple of
different queries that can be displayed in the datasheet. The queries
are available in a combo box on the main form. The problem I am
having is that when I change the query all the column widths remain
the same. This doesn't look very good. I can't figure out a way to
set the column widths.

I have tried..

Subform.controls(Name of Column).columnwidth = IntColumnWidth

However, It doesn't change the width of the column in the subform and
if I debug.print Subform.controls(Name of Column).columnwidth i dont
get a value equal to IntColumnWidth

it just gives me whatever the current width size is.

Thanks for any help.
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Sometimes the easy way to fix this is to have 2 subforms ( 1 for each query)
sitting on top of each other. Then you just need some code in the combo after
update like -
if combo = something
then
Me.subform1 visible = true
me.subform2 visible = false
etc
HTH
David B

A Clark <ag*********@hotmail.com> wrote in message
news:32**************************@posting.google.c om...
I have a subform that displays a datasheet. There are a couple of
different queries that can be displayed in the datasheet. The queries
are available in a combo box on the main form. The problem I am
having is that when I change the query all the column widths remain
the same. This doesn't look very good. I can't figure out a way to
set the column widths.

I have tried..

Subform.controls(Name of Column).columnwidth = IntColumnWidth

However, It doesn't change the width of the column in the subform and
if I debug.print Subform.controls(Name of Column).columnwidth i dont
get a value equal to IntColumnWidth

it just gives me whatever the current width size is.

Thanks for any help.


Nov 12 '05 #2

P: n/a
A Clark wrote:
I have a subform that displays a datasheet. There are a couple of
different queries that can be displayed in the datasheet. The queries
are available in a combo box on the main form. The problem I am
having is that when I change the query all the column widths remain
the same. This doesn't look very good. I can't figure out a way to
set the column widths.

I have tried..

Subform.controls(Name of Column).columnwidth = IntColumnWidth

However, It doesn't change the width of the column in the subform and
if I debug.print Subform.controls(Name of Column).columnwidth i dont
get a value equal to IntColumnWidth

it just gives me whatever the current width size is.

Thanks for any help.


I do something like this. On the fields I want to Hide, in the Tag I
put -1. Where I want the default width, I put a 0. If I want SizeToFit
I leave empty

Sub SizeDS
Dim ctl As Control
For Each ctl In Me.Controls 'change to something like

If ctl.ControlType <> acLabel Then
Select Case ctl.Tag
Case "-1"
ctl.ColumnHidden = True
Case "0"
'default size
ctl.ColumnWidth = -1
Case Else
'size to fit
ctl.ColumnWidth = -2
End Select
End If
Next
End SUb

On the OnOpen event I could enter
SizeDS

If you want to specify a specific control from the main from try
something like
Me!SubFormName!Control.WhateverProerty = ...

Nov 12 '05 #3

P: n/a
ag*********@hotmail.com (A Clark) wrote in message news:<32**************************@posting.google. com>...
I have a subform that displays a datasheet. There are a couple of
different queries that can be displayed in the datasheet. The queries
are available in a combo box on the main form. The problem I am
having is that when I change the query all the column widths remain
the same. This doesn't look very good. I can't figure out a way to
set the column widths.

I have tried..

Subform.controls(Name of Column).columnwidth = IntColumnWidth

However, It doesn't change the width of the column in the subform and
if I debug.print Subform.controls(Name of Column).columnwidth i dont
get a value equal to IntColumnWidth

it just gives me whatever the current width size is.

Thanks for any help.


From the main form I use:

'Code from somewhere on comp.databases.ms-access:
MySubform.Form.MyColumn1.Properties("ColumnWidth") = 1000 '1440 Twips
per inch
MySubform.Form.MyColumn2.Properties("ColumnWidth") = 880

This should allow you to change the Column Widths for the different
queries. I put these commands between the MySubform.Form.Refresh and
the MySubform.Visible = True in my case.

If I use multiple subforms sometimes having a subform with a caption
that simply says "Updating, please wait...." allows me more
flexibility in updating tables via code when bound controls on the
subforms are used. I also like to see if the underlying query results
in any records so that I can show something more interesting than a
blank line.

Also, be aware that if you decide to convert your database containing
subforms to VB you may have to get creative.

James A. Fortune
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.