fit to column width

R

riccifs

Hi to all,
does everyone to know how to fit the column width of a subform in data
sheetview?
I read about it but I'm still having problems to make it works.
A couple of days ago I saw a sample db that have two buttons in its
main form, one to fit to column width and the another one to reset
column width.
Unfortunately it's a .mde file (a compiled one) so I can't see the
code beyond the two buttons.
I'd like to do something like that on my form too.
How can I do that?

Please help me!
Many thanks, Stefano.

P.S.
this is the link where I downloaded the sample db I was talking about
above:
http://www.rogersaccesslibrary.com/...l to Access 2000-XP Converter Utility program'
 
S

Steve Sanford

I haven't used the sample db at the link I gave you, but it looks easy to use.

I am not sure what you are trying to do. Are you changing the recordsource
and trying to fit all of the columns, or you want to autofit the column width
to the widest text, or ???

If you have written any code, would you post it?


I set up a form with a subform. I added two buttons. The first button
(Command21) sizes the column to fit the size of the visible text default
width and the second button (Command22) set the columns to a specified width.


The code for button "Command21" I used is:

'-------------------
Private Sub Command21_Click()
Me!subformAgain.Form!id.ColumnWidth = -2
Me!subformAgain.Form!SalesTax.ColumnWidth = -2
End Sub
'-------------------
(see Help)
to set the column width to the default width, use -1
to fit the size of the visible text default width, use -2


And the code for button "Command22" is:

'-------------------
Private Sub Command22_Click()
Me!subformAgain.Form!id.ColumnWidth = 1440 * 0.5
Me!subformAgain.Form!SalesTax.ColumnWidth = 1440 * 1.25
End Sub
'-------------------
(width is in twips, where 1440 twips = 1 inch)



HTH
 
R

riccifs

I haven't used the sample db at the link I gave you, but it looks easy to use.

I am not sure what you are trying to do. Are you changing the recordsource
and trying to fit all of the columns, or you want to autofit the column width
to the widest text, or ???

If you have written any code, would you post it?

I set up a form with a subform. I added two buttons. The first button
(Command21) sizes the column to fit the size of the visible text default
width and the second button (Command22) set the columns to a specified width.

The code for button "Command21" I used is:

'-------------------
Private Sub Command21_Click()
Me!subformAgain.Form!id.ColumnWidth = -2
Me!subformAgain.Form!SalesTax.ColumnWidth = -2
End Sub
'-------------------
(see Help)
to set the column width to the default width, use -1
to fit the size of the visible text default width, use -2

And the code for button "Command22" is:

'-------------------
Private Sub Command22_Click()
Me!subformAgain.Form!id.ColumnWidth = 1440 * 0.5
Me!subformAgain.Form!SalesTax.ColumnWidth = 1440 * 1.25
End Sub
'-------------------
(width is in twips, where 1440 twips = 1 inch)

HTH

Hi Steve,
thanks for your replay.
What I was trying to do is to auto fit the column width to the widest
text just clicking a button.
I used your code and now it works great, I don't know where I was
making mistake in the past.
Many thanks for your help!

I really do appreciate your interest to my question.
Bye, Stefano.
 

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