Auto expand memo field in form or include subreport.

G

Guest

I have a form with a tabstrip on it. The tabstrip opens various subforms and
such. One of my subforms is not acting right. The source table is a query
that returns an ordered set of records with two fields: Question, Response.
Both fields are memo fields with an indeterminate amount of data in them. It
is used as a script or Q&A bank. In the form I have the fields set to
auto-grow and shrink. This seems to only take effect when printing the form
though.

I want the form to be able to display the complete data in each record, no
matter how long it is. Is it possible to either put a print preview in a form
on the screen? Another possibility would be to include a sub-report in the
form in this place, but I cannot seem to find where this is even possible.

Once I get the data to display correctly, I would then add code to change
the exact data displayed by changing the underlying query and then refreshing
and/or requerying.

Thank you in advance for any help you can provide. I have learned a lot from
just reading other's posts on this forum.

Regards,
Keith
 
A

Arvin Meyer [MVP]

You are correct that CanGrow/Shrink is a print only attribute. The only
suggestion I have is to use the form's Current event to to a character
count, then set the textbox's height based on the number of characters.
Here's some aircode that might give you an idea:

Sub Form_Current()
Dim lngCount As Long

lngCount = Len(Me.txtMemo & vbNullString)

Me.txtMemo.Height = (lngCount / 40) * (1440 / .17)

End Sub

What I've done is to count the characters and divide by 40 characters per
line (just measure youre own lines) then I multiplied that by the height of
a 10 pt textbox. 1440 is the number of twips per inch.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
S

Stephen Lebans

Arvin another possible solution is here:
http://www.lebans.com/textwidth-height.htm
TextHeightWidth.zip is a replacement for the Report object's TextWidth
and TextHeight methods. It is multiline aware and can work in both
Report and Form views. Includes a sample report to show you how to
autosize individual controls with different formatting on the same line
to simulate RTF style text.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
A

Arvin Meyer [MVP]

Stephen Lebans said:
Arvin another possible solution is here:
http://www.lebans.com/textwidth-height.htm
TextHeightWidth.zip is a replacement for the Report object's TextWidth
and TextHeight methods. It is multiline aware and can work in both
Report and Form views. Includes a sample report to show you how to
autosize individual controls with different formatting on the same line
to simulate RTF style text.

Well just spank me for not looking at your website first <g> I shoulda'
known that you would have solved that. The method I explained I used 8
years ago and never had an occasion to need it again.

Keith, Stephen has solved some of Access's most difficult formatting
problems (and dozens of others as well) If you have a spare week or 2, you
can find yourself lost in some very neat programming tricks on his website:

http://www.lebans.com

--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
G

Guest

Stephen,

Thanks for the demo. What I saw is exactly what I am looking for. I
will delve into it and see how it works then impliment it into my database.

This would be the second set of code I have used from your website. The
first was picture handling and storing.

Is there a way to make a form's background transparent? In this same
application I asked about here, it would be nice to be able to pull up these
subforms and use the background from the parent form. The background is
patterned such that it is really hard, if not down right impossible, to line
them up to match.

Thanks for the help.
Regards,
Keith.
 

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