text in the report

  • Thread starter Thread starter Frank Dulk
  • Start date Start date
F

Frank Dulk

Hello, I have several text boxes in a report! wanted to know
if it was possible to do the following:
When opening the report he asked me a question. Which the
size of the letter. If it placed 12, the text in the report
appeared to 12, if it placed 8 the text would appear of the
size 8.
 
Hey Frank

What you need to do is go to the properties of your
report, and click on the "Events" tab. You should see "On
Open" as the first listing in the tab. For the related
Combo box, select Event Procedure (the only option in the
combobox), and then click on the button after the box
(next to the arrow that's in the combo box) that has "..."
as the caption. This will bring you into VB Editor,
within the procedure "Report_Open"

In there, what you want to do is use the function
InputBox, and get back from it a value. For instance, if
I wrote a line of code saying

hold = InputBox("What is the size of the letter?")

when the report opened, a box would come up, with a
textbox in it, asking me "What is the size of the letter?"
and then let me input it.

Then, what you want to do is set the textbox to that
value. You want your textbox to be unbound for this to
work(if you click properties in the design view,
the "ControlSource" under the "data" tab should be
blank). So, then, your next line of code would be

Me![TextBoxName] = hold

And that's it. At least, it should be. So, let me put
the two lines together for ease of copy pasting, and just
remember to substitute "TextBoxName" with the name of the
text box you are using.

hold = InputBox("What is the size of the letter?")
Me![TextBoxName] = hold

You can do more things with your inputbox, like give it a
title and such, but this is just the basics of what you
need.

Sullivan
Intermediate Access User
 
Frank,
If I read your post correctly, you wish to be able to change the font size
when the report is run.

In the Report's code window Declaration section, write:

Dim intSize as Integer

In the Report's Open event, write:

intSize = InputBox("What Font Size?")

In the Report's Report Header Format event:
To change all text controls:

Dim c As Control
For Each c In Controls
If TypeOf c Is TextBox Then
c.FontSize = intSize
End If
Next

The above will change all text controls to whatever font size was entered.

If you wish to be more selective, and change just one or two controls, then,
instead of the above code in the Report Header, write:

[ControlA].FontSize = intSize
[ControlB].FontSize = intSize

Only those 2 controls will be affected.
 
Back
Top