473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Datasheet Subform - Change the width of a column

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
3 13355
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marble | last post by:
Hi all: In DB2 CLP mode ,how to change a column name expect to recreate a table? Thanks . Your friends.
3
by: A Clark | last post by:
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...
3
by: Thelma Lubkin | last post by:
I'm resubmitting a question that went unanswered a while ago. I'll try to rephrase it. I have a hierarchical form that presents data on an 'organization'. It has 2 subforms, the first a...
10
by: Michael R | last post by:
Hello to all. In what way can I update a certain selected records' values on a datasheet subform using a command button which is located on the main form? Thanks and cheers.
4
by: paulw4 | last post by:
I have a mail form that has a datasheet subform, there can be up to sixty items in the datasheet. The data sheet has three fields: AttID, AttName, AttYN The object is for the enduser to select...
0
by: WPW07 | last post by:
Hello Everyone, I stumbled onto something interesting and was wondering if anyone else has experienced it and how they fixed it. I've posted to several forums to no avail. I've got a...
4
WyvsEyeView
by: WyvsEyeView | last post by:
I am doing the very standard thing of filtering the contents of one combo box based on another combo box. I've done it many times, but always on a main form. Now I'm trying to do it on a datasheet...
3
by: pzh20 | last post by:
I have an unbound form/subform where I populate a combo box on the main form, and using the onchange event, display fields from a table in a datasheet subform. I want to add a new record via the...
7
by: MayoM | last post by:
Access 2003 has suddenly reordered the sequence of columns in a datasheet subform. Specifically the last column has stayed in place but the others are back to front. There are about 50 columns in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.