How can I make the column widths of a list box in MS-Access2007 automatically size themselves correctly? - ms-access

Background info:
I was handed a "Tool", which was made using MS-Access 2007, and asked to add some things... The tool is basically a collection of options for querying a database. On a form titled CreatedReport there is a listbox that is bound to a table called analyzed which has all of resulting data from the query/queries that ran. The original creator of this tool set the column widths to specific values but with the new collection of possible results, those widths are very far off.
Desired Outcome:
The final result I want to achieve is, of course, to have the columns be the correct widths for the info that is in the columns. As long as that is achieved, I really don't care which route I have to take to get there.
Question:
How can I get the columns in a listbox in MS-Access 2007 to be sized appropriately for each use? Is there an auto-size feature I haven't stumbled across yet or do I need to hard code the set of column widths for each group? This wouldn't be too hard to do since there would only be about 4 or 5 different groups but I would prefer for the process to be automatic if at all possible.

Another approach would be to have the results returned in a sub form datasheet view, then the user can adjust the column widths also to set the widths automatically use code like this:
Example
This example takes effect in Datasheet view of the open Customers form. It sets the column to fit the size of the visible text.
Forms![Customers]![Address].ColumnWidth = -2
You could put this code into the Current Event of the sub form.

I don't think that Robert Harvey's answer is actually responsive to your question.
What you need to do is:
calculate the maximum length of the values in each column,
AND
figure out, based on the font in use, how wide the column should be.
Note that you may not actually want to set it to the maximum width if the value exceeds a certain threshold.
I don't know to do the second taks, but I suspect Stephen Lebans has already done the work on it. You might want to search his website for it.

Last time I checked, you still had to write code for this.
Your best bet is to use a resizer someone has already written. Here is a good one. It's old, but it shoul still work:
http://www.jamiessoftware.tk/resizeform/rf_jump.html

This is a quick solution that should help when you want to set up listview columns of different widths, and you know in advance the widths you want (eg, you know that column X will always be a 2-character State abbreviation, and column Y will always be a city name).
Just supply all the widths as a single semi colon-delimited string. Code each width as a number and a unit, such as 'in' or 'cm'. This worked well for me: Me.lsvPayHist.ColumnWidths = "1.0 in;0.8 in;1.0 in;1.0 in;2.0 in"

Related

ssrs keep certain "chunks" of text "atomic" within a report header

I have some text I want to keep "atomic" within a report header. The text in question is the "Period Ending Date: 1/15/1998". It is OK if that block of text wraps down below, but I would like to keep the whole block of text together on one line. This has to be dynamic however, as the text will grow and shrink dynamically--sometimes the server and database and company name will be short and everything fits on one row, sometimes long even the database name will need to wrap.
And this is how I have it defined in the expression
Is keeping it "atomic" possible?
As the comments say you basically have two options, either make the text box wide enough to fit any possible combination of company, server, database and end date that could occur - you can use max(len([your fields])) in SQL to determine the maximum possible characters and then figure out the width from your font information - or you can put the separate chunks of information into separate text boxes and arrange them however is most aesthetically pleasing to you. Personally I'd have a company name box on one line, the Server and database beneath it and the end date beneath that. Up to your preference though obviously.
#Jeff.Clark, I guess you need to rethink the design. I agree with #Viking's comment. As far as i know, what you are trying to achieve is not possible in SSRS (keeping the Can Grow = False) and want to wrap it on the field level not the word level. I tried using it in the placeholder but it is splitting the field.
However, if your requirements are very critical and no matter what you have to do it in this way then i think you can achieve it by determining maximum characters the cell can accommodate in one line and then subtracting the SUM of LENGTH of the the fields+ the text(ex: "Totals per payroll period") and find out a position in your string to insert VBCRLF so the rest of the data will go to next line. Without the original expression i will not be able to provide the accurate updated expression but it will be nested IIFs to get the position of VBCRLF. I personally do not prefer this method because it will take lot of processing on the report design level and can affect the overall performance of the report as well as not very pretty when it comes to the maintenance of the report.

Access UI chart text legend sorted as number

I have searched for a solution but I can't find one suitable on this problem.
I have a chart in access where the Y-axis is text but starts with a number, so up along the y-axis i get this:
I know why, but I don't know how to fix it.
They all have an ID which is fine. I can chose to put the ID on the Y-axis, but then the kW range can't be visualized.
How is this changed?
Changing the text to number is not possible as it needs to be like "a-b kW".
Thanks in advance.
For those who might get this problem, I found out why.
When selecting the data, it chose to use the "Total" function, and "Avg" because that is what the values are. (The picture below says "Group By" but it was automaticly set to "Avg". I just forgot to change it when i snipped for stack.
That results in:
But if i remove the "Total" function i get this:
So, removing the "Total" function works here...
In your query, can you sort by ID, but not display it (e.g., in the query designer, sort 'descending/ascending' on the ID field, but clear the 'display' check box)?
As an aside, I've always had a tough time with Access charts... on my last project, the customer wanted a rather complex bar chart, and I ended-up drawing and resizing rectangle objects to get the look that the customer wanted.

Fixed row in SSRS Child Group

Hi below is an image of my report which utilizes a toggle. The toggle data is only one row which will then contain 50+ records, as well as column headers for that data.
I am wondering if there is a way to Fix these (sub) column headers after they have been toggled open?
I can get the first row Fixed, and when using the same techniques on the Child Group I receive the message:
The tablix 'Tablix1' has an incorrectly set FixedData property. FixedData is not allowed to be set on row TablixMember, unless it is also set on the first row.>
But, when it is set on both rows, neither of them act as though they are Fixed Data :/
I don't even need the first row fixed but if anybody has suggestions please help!
Below is a link to a picture of the report, you'll notice the yellowish row with my toggle, and i would like the column headers below that to be fixed. Is this possible??
https://www.flickr.com/photos/125488420#N02/14450152092/
The row groups below: (I KNOW ABOUT (Static) vs Static.. This image is of the original version. Please just note which rows should be Static headers, please done make that the only content of your response)
That said, I think my grouping is the issue, but I'm struggling to get it the way I want
https://www.flickr.com/photos/125488420#N02/14450154942/in/photostream/
I have an answer, though it is not what I'd hoped for.
Firstly, in order to have a static row, the first row must ALSO be static.
Further, any static rows need to be "Contiguous" meaning that there cannot be a gap between them (ie rows 1-3 is ok but not rows 1 & 3 only)..
I experimented with some workarounds such as using multiple tablixs, row groupings, etc.
And in the end it was unsuccessful, and not worth continued effort. Unfortunately users will not be able to have the headers follow them down. :(
If somebody has a solution or Non-Contiguous Fixed data is allowed in future releases please post!

how to make a form designer

The Problem in Hand:
I want to make a form designer where user can drag and drop fields of different type and design the layout too, some what similar to wufoo form builder but here the layout is limited to single column whereas I want to make something where user can make the layout as they want.
I understand how to do in single column view, but could not understand how to achieve multiple column layout eg: row 1 there could be 3 elements, row 2 one element stretched to full length, row 3 there could be just 2 elements etc.
What I tried:
I have tried with jquery UI sortable to make a single column layout with using div where new elements can be dragged and repositioned.
Any suggestion on how to proceed further will be helpful
I have tried searching StackOverFlow and google but could not find any link on a similar topic. If anyone could point me to the same, it will be also helpful.
When you reorder elements on wufoo form builder, you can only drag'n'drop up or down. Remove that restriction and as soon as one element is dragged across a certain threshold, it "belongs" to the next column. If the "old" column was the first or last one and the line that the element was moved over was to the "outside" of the form, add a new column there, until the maximal number of columns is reached.
If the used drags the last element of a column into another column, remove the now empty column on element-drop.
You could also remove the dynamic adding/removing of columns and juist have a button ("remove column" & "add column") to do it by code.
An example for the dropping in another column can be found here: http://jqueryui.com/sortable/#connect-lists
Hope this helped!
Edit:
http://jqueryui.com/sortable/#portlets and http://jqueryui.com/sortable/#empty-lists also have elements that you could look into. Good luck! Sounds like a nice project. Can we see any progress or beta?

How to make a drop down list as wide as its biggest item

I have a drop down (Combo Box) in MS Access that I would like to make as wide as it's biggest item. At the moment it's currently set to the following:
ListWidth 3.5"
ColumnWidths 1.75";1.75"
This is ok for values that are smaller than this but a problem occurs when longer values come in. I googled the question and found a way to dynamically make a drop down bigger here but this seems rather complicated for what I want.
Does any one have any suggestions - like would it require iterating over the source contents, checking each individual value for its length and if its bigger than the biggest to that point - set it as the biggest and move on until the end of the values is reached.
Thanks
First I would do a query with the SQL string
SELECT TOP 1 * FROM Table ORDER BY Len(Field) Desc
Then create a recordset, do a movefirst and finally multiply the length of the string with the size of one character.
Sorry for any fault in my text. English is not my first language.