How to increase the size of input box in MS Access reports or forms based on user input? - vba

I have a text box in MS Access Report which is set to unbound. I want to be able to collect an address in that field which can be any length based upon the customer address. I right clicked the box and set the size property to "To-Fit". However this did not do anything at all. The report needs to be printed which is why I cannot have a part of an address cut off because of the size of the text box.
Is there a way to make the size of the text box dynamic?
Thank you

Unfortunately there is no such feature for reports. For form controls you could use Horizontal Anchor but not for reports.
So you have two possibilities to let your adress not be cutted:
1: Let it grow vertically
To achieve this you would have to set the property Can grow of both, the textbox and the containing section to Yes.
If the text now doesn't fit in the textbox it will be resized in height.
2: Control it via VBA
You could use the format event to control the width of the textbox via VBA.
Here is an example of how to do this, but I didn't ever try it.
Unfortunately it is in mdb format, so you would need an older Microsoft Access Version (I expect Microsoft Access 2007 should be able to, 2003 for sure) to open it and grab the code.
http://www.lebans.com/autosize_textbox.htm
It uses Windows APIs and could be not so easy to get it running.
What it does (just the steps):
It first calculates the width of the text to be displayed in respect to the current font, fontsize and its properties.
Knowing this the control can be resized regarding.

Related

VBA ActiveX control changes size after sharing

I have a simple excel form with an ActiveX control (ListBox)
When I share this over email, the recipient does the following steps:
1. Open the excel
2. Enable Content for the macro
Now - the ListBox grows in size.
I'm unable to dynamically resize or figure out the exact event for "Enable Content".
Is there anyway I can retain the dimensions of the ListBox?
Your problem has nothing to do with sharing the document via email. It has everything to do with window scaling. To prove this to yourself try connecting to a projector with the the excel document open. Use some Active X controls and they will shrink or Expand. I've had this problem and found the only way to avoid it in a reasonable manor is to implant a form inside the excel document that holds all the needed controls or ensure the end user is not scaling their display in any manor.

Vertical Text in Access 2003 Forms

I have been trying with no success lately to implement vertical text on an Access 2003 form im designing. There is a vertical option in the properties of every text box, but its not in the right direction. Text boxes marked with the attribute vertical = true start their text at the top side and then run downwards, exactly not as I want.
So my question is:
Is there native support for vertical textboxes other then the vertical attribute in Ms Access 2003
Failing #1, is there a way to shift text in text boxes by 180°.
Is #1 or #2 dependant on wether or not you have fixed text or text obtained from a data source.
Microsoft really messed this up by only implementing the one vertical direction, and not the other. :(
No
If you are desperate enough, you can try one of the solutions by the Great Wizard aka Stephen Lebans: http://lebans.com/rotatetext.htm or http://lebans.com/xrotatetext.htm
There are other external solutions (commercial), like Total Access Components.
You'll have to try it out, but in comparison to the 90° rotation, making a label caption dynamic or giving a text box a constant text is trivial.

VBA script to insert anchor position for autoshapes in Microsoft Word 2007

I'm beyond the limits of my kindergarten-level VBA skills so would like to ask if anyone here can help me write a VBA script to help me work stepwise through my Word document and adjust the anchoring position of all the AutoShapes in the document.
I have a 400-page book in Microsoft Word with at least one and sometimes several marginalia (sidenote) on each page in a thin column to the left of the main body text column. These sidenotes are a concise 'pointer' to a particular point made in the body text and need to appear directly to that point's left.
Each sidenote is in its own AutoShape (within a textbox in that shape). The AutoShapes were placed by the author in an inconsistent way. Mostly they are anchored to a position on the page.
However, I need to repaginate. This will cause the body text to flow differently and I need the sidenotes to flow with it (approximately or exactly)!
So before I repaginate I want to make sure I anchor each AutoShape to the paragraph it belongs to and not to the page it is currently on.
I don't know if that can be done automatically, since I don't know how Word could deduce a purely spatial relationship between an AutoShape and a paragraph.
So I'm guessing I have to make do with a "semi-automatic" process. Something like this:
Press a button to start VBA script
Select next AutoShape
Prompt for user to enter cursor in body text where anchor is to be placed
Resume macro
Place anchor for that AutoShape in that position
Change vertical position paramater of AutoShape to "relative to paragraph"
and "0 mm"
(Alternative, not 0 mm but another value deduced to more
accurately position AutoShape)
Change width parameter of AutoShape to
a particular fixed value 37 mm (some of them were a little
inaccurately drawn)
End cycle and go back to beginning to
Select next AutoShape
Hope that is all understandable.
I've tried to record a VBA script to do some of this but have no idea how to build in the user prompt.
Any help much appreciated!
Craig
You may be better off creating a macro that works on one shape at a time, or anchor all the shapes manually (which you're almost doing anyway) and then write a macro to take care of the various parameters and settings you want.
If you really want to prompt the user while the macro is running you'll need to look into modeless dialogs (not possible on the Mac). See this link: http://www.bettersolutions.com/vba/VXV113/SE846743531.htm
Basically, you'd have to create your own dialog and then show it modelessly so that the user could still place the cursor before hitting OK. If you're new to VBA, this could be difficult to set up.
While searching for solutions to this, I found a post on another forum from someone trying to do something very similar. He was developing a set of tools for editors using Word and until I find the ultimate solution I am using his "Shapes" tool which allows me to change parameters on each AutoShape I select at-a-click instead of opening up and closing a dialogue box each time, plus selecting a different tab each time... His tools can be downloaded at his Editors' Toolkit website.

TextBox Not Displaying Full Text in Microsoft Access

Currently I'm working on generating report using Microsoft Access. I have encounter problem where I'm unable to display full text in the text box. Control Source for this text box is from SQL Query.
This is example on what I'm getting right now:-
Appreciate any help or suggestion.
While viewing the form in Datasheet View (not Design View), double-click the edge of the column or drag to desired width. You must save the form for the formatting to stick. The width of datasheet form columns are not tied to the Width property in the property sheet. That's how it works in Access 2010 anyway.
You have to expand the Size of the text box that is all.

ReportViewer: two text colors, one cell

Is it possible to have 2 areas of text in one cell such that each can have a different color? You can do this in crystal reports but I cannot see a way to do this in ReportViewer. What it is doing is essentially highlighting an important text fragment if it appears in a cell description to draw the users attention. I am fairly new to reportviewer so it for now I am assuming it's my lack of knowledge that is making this difficult. I am using VS2010.
Thanks.
Turns out VicarlnATutu wasn't quite right.
You can do this, but only if you are using VS2010 (which I am) because it includes the new SSRS rendering engine for SQL-Server 2008. This allows you to put some basic HTML into a field and have multiple formats in one cell. For more info see below:
http://msdn.microsoft.com/en-us/library/cc645967.aspx
http://msdn.microsoft.com/en-us/library/cc627491.aspx
One thing that tripped me up is what they call a 'placeholder' in the MS documentation is the little bit of text inside the textbox control that shows up by default. You can select two different things on the control in VS2010. One is the textbox itself. Right clicking on the textbox gives you 'text box properties'. The other thing you can select is the default text INSIDE the textbox. Right clicking on this 'placeholder' text gives you a different context menu where you can select 'placeholder properties'. This is where you can change the cell to accept HTML.
No, unfortunately not. I don't know if there are custom controls out there for ReportViewer, but the built-in TextBox only supports setting color (be it Foreground or Background) for the entire thing.
ah, good to know. kind of a unintuitive way to tell a TextBox to display HTML, but nice to know that you can!