Full Version: Automatic adjusting colums/form...
UtterAccess Forums > Microsoft® Access > Access Forms
morpheus
Hi,
That I would like if its possible is a column which automatically adjusts itself to the highest length text string... and then adjusts the rest of the form with it...
So say if I run a filter on my form it would find the largest text value and adjust that column to that width and then get the rest of the form to fall into place if its possible...
Do you know what I mean?
Also I have attached a copy of my database...
Many Thanks
James
Jack Cowley
Within the last few days I saw a post here on this same subject. I am not sure which forum it was in but you can seach and see if you can find it. You can also search Help (from the code editor) for ColumnWidth to see how to programmatically adjust the width of a column in Datasheet view.
th,
Jack
DougY
James,
Back may be referring to this post .
HTH
mishej
Sure, run through the recordset saving the longest number of chars in each field. Then multiple that be a TWIPS value equal to a single char (perhaps 144) and use the .ColumnWidth property of a control to set the width (in a Datasheet view).
I'm doing that in a project right now.
There was no attached copy of your db. Compact it, zip it up, ensure its under 500K and then attach it along with your post.
morpheus
On my very first post there is my database...
lso please could you rephrase hat you have just said misei as I have no idea what you have said...
Also I will check that post out as well I will do that next...
Thanks Guys...
James
Jack Cowley
Doug -
Thanks for your response as that is the post I had in mind!
Jack
DougY
No problems, I remembered seeing it posted... frown.gif
Edited by: DougY on Sat Nov 27 19:27:28 EST 2004.
morpheus
Thanks for that
will be putting that code into my database tonight and I wll let you know how I get on tonight..
Thanks
James
morpheus
Hi I have the following code in place:
CODE
  
Private Sub Form_Current()
'This will resize the columns to the exact length of the data
With Me
.Title.ColumnWidth = -2
.Artist.ColumnWidth = -2
.SubTitle.ColumnWidth = -2
End With
End Sub

It dosent seem to do anything at all with my colums... or anything...
What am I doing wrong?
Many Thanks
James
Jack Cowley
Hmmm. Not sure what is going on as Access help says that -2 should do what you want...
ack
morpheus
It dosent seem to work or do anything what so ever its really strange...
However in the link that was posted that guy has no problems with it...
This is strange...
Oreally would like this to work but obviously the code would have to be spot on or this to happen...
Justt to clarify the code above would indeed move tthe columns width to -2 of the largest text in that colums filtered or unfiltered?
Many Thanks
James
Jack Cowley
The code works but it only works with forms in Datasheet view, not Continuous Form view.... Take your form "qryWeeklyUpdate subform" and change it to Datasheet view and try the code...
Hth,
Jack
morpheus
I will do thanks for that but I really need it to run under form view...
any Thanks
James
Jack Cowley
If you want to adust column width using a continuous form then you will have to write the code yourself as I am not aware of any code from Access, similar to the ColumnWidth code, that does what you want.
You are welcome and continued success with the project.
Jack
morpheus
Thanks for that...
would need help with that though...
Does anyone in here know how I am to achieve this?
Many Thanks Again for your assistance...
James
Jack Cowley
James -
The problem, as I see it, is finding the field in each 'column' with the longest string. This would mean looping through each record and finding the longest string for that 'column' then adjusting the width accordingly. Then moving to the next field, finding the longest string, etc... Is it really worth it?
Have you thought about making the controls taller so you can wrap the text in the control? This way you can have a constant width yet show more information. Just a thought...
Good luck with this!
Jack
morpheus
Ok could that be ok with my database?
will give it a go tonight?
Many Thanks
James
morpheus
Right thanks for that I will give it a go... And see how I get on...
Thanks Again
James
Jack Cowley
James -
You are welcome and continued success with the project....
Jack
morpheus
Hi I have changed the hight so that it wraps the text but now it looks rather large...
Could you please have a look at it and see what you think?
It could just be me.
Many Thanks
James
Jack Cowley
James -
think it looks fine, but since you do not have many choices I think this is the best of the lot. I notice that 'Title' is the only control that you made taller and I only saw one title that wrapped. It would seem that most of the titles are short so you may want to reconsider the height issue and just go for the wider look rather than the taller look....
Good luck!
Jack
morpheus
Its just that if I go wider then the users have to keep going across and also the Artist field would need to be widened as well for some of them...
That would you recommend? Widening the form or changing the height again?
Many Thanks
James
Jack Cowley
I would change the height of the controls... Scrolling to the right is something that I try to avoid...
th,
Jack
morpheus
Ok thanks
will give it a go...
James
Jack Cowley
You are welcome and remember that this is your database and you can have it look any way YOU like...
ack
morpheus
Yeah I know its just that I want it to be easy for the users...
Thanks
James
Jack Cowley
If you have a couple of people near by then have them run the db without any coaching from you. You will quickly find out how intuitive it is to use and they will also tell you how it looks to them.
ack
morpheus
Yeah good point I will throw it round a couple of people and see what they say...
Thanks for that
James
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.