Change Font on Character Count

G

Guest

I have a form from the CBOE.

The form is used to give responses by students, but has limited space.

This worked in Acces 2.0 and Access 97, now it is no longer working!

I count the total number of characters on a page. If the count is in
certain ranges then I set the font accordingly.

Current Code

Dim rprt as Report

Set rprt = Me

With rprt
If Me!TextA > 1400 then
.fontsize = 13
End If
If Me!TextA > 2100 then
.fontsize = 12
End If
If Me!TextA > 2800 then
.fontsize = 11
End If
If Me!TextA > 3500 then
.fontsize = 10
End If
If Me!TextA > 4200 then
.fontsize = 9
End If
If Me!TextA > 4900 then
.fontsize = 8
End If
If Me!TextA > 5600 then
.fontsize = 7
End If
If Me!TextA > 6300 then
.fontsize = 6
End If
If Me!TextA > 7200 then
.fontsize = 5
End If
End With

After 10 years this code has stopped working on my Access 2004 and the
Access that came with Vista.

The code worked fine until I went to remove 3 lines of the above script.

The Font Value on the properties of the Text field is 7. I know the
documentation claims the smallest font is 8, but that is incorrect. We even
have a report that prints in Font Size 4.

Does anyone know why the above code will not override the default font?

Thanks in advance

John
 
M

Marshall Barton

John said:
I have a form from the CBOE.

The form is used to give responses by students, but has limited space.

This worked in Acces 2.0 and Access 97, now it is no longer working!

I count the total number of characters on a page. If the count is in
certain ranges then I set the font accordingly.

Current Code

Dim rprt as Report

Set rprt = Me

With rprt
If Me!TextA > 1400 then
.fontsize = 13
End If
If Me!TextA > 2100 then
.fontsize = 12
End If
If Me!TextA > 2800 then
.fontsize = 11
End If
If Me!TextA > 3500 then
.fontsize = 10
End If
If Me!TextA > 4200 then
.fontsize = 9
End If
If Me!TextA > 4900 then
.fontsize = 8
End If
If Me!TextA > 5600 then
.fontsize = 7
End If
If Me!TextA > 6300 then
.fontsize = 6
End If
If Me!TextA > 7200 then
.fontsize = 5
End If
End With

After 10 years this code has stopped working on my Access 2004 and the
Access that came with Vista.

The code worked fine until I went to remove 3 lines of the above script.

The Font Value on the properties of the Text field is 7. I know the
documentation claims the smallest font is 8, but that is incorrect. We even
have a report that prints in Font Size 4.

Does anyone know why the above code will not override the default font?


Are you sure that TextA contains the number of characters in
whatever it is you are counting?

Also, it is very unusual to be using Me.Print to display
text, especially when it is that long. Why don'l you just
use a text box and set its FontSize property instead of
messing with the Print method?

When you post code to a newsgroup for others to see, please
use Copy/Paste so we don't waste time debugging typos.
 
K

krissco

I have a form from the CBOE.

The form is used to give responses by students, but has limited space.

This worked in Acces 2.0 and Access 97, now it is no longer working!

I count the total number of characters on a page. If the count is in
certain ranges then I set the font accordingly.

Current Code

Dim rprt as Report

Set rprt = Me

With rprt
If Me!TextA > 1400 then
.fontsize = 13
End If
If Me!TextA > 2100 then
.fontsize = 12
End If
If Me!TextA > 2800 then
.fontsize = 11
End If
If Me!TextA > 3500 then
.fontsize = 10
End If
If Me!TextA > 4200 then
.fontsize = 9
End If
If Me!TextA > 4900 then
.fontsize = 8
End If
If Me!TextA > 5600 then
.fontsize = 7
End If
If Me!TextA > 6300 then
.fontsize = 6
End If
If Me!TextA > 7200 then
.fontsize = 5
End If
End With

After 10 years this code has stopped working on my Access 2004 and the
Access that came with Vista.

The code worked fine until I went to remove 3 lines of the above script.

The Font Value on the properties of the Text field is 7. I know the
documentation claims the smallest font is 8, but that is incorrect. We even
have a report that prints in Font Size 4.

Does anyone know why the above code will not override the default font?

Thanks in advance

John

John,

I have never seen the fontsize of the report used to modify the
default font. This attribute should still work with the controls on
your report.

Try something like this:

On format event:
select case {# of characters}

case is > 7200
changeFonts(5)
case is > 6300
changeFonts(6)
.. . . etc

case else
changeFonts(someDefaultFontSize)
end select
end sub


Now create a new sub:

private sub changeFonts(intNewFontSize as integer)
on error resume next 'included to bypass controls that don't contain
the .fontsize property
dim ctrl as control

for each ctrl in me.controls
ctrl.fontsize = intNewFontSize
next ctrl

'Cleanup if desired and exit.
end sub

This will change the font size on your controls rather than on the
report itself. Marsh has a good point - what method are you using to
count characters? Is there more than one text box on your report?

-Kris

PS - what is CBOE?
 
G

Guest

Marshall;
Thanks for getting back to me. I was not the original
programmer of this code. However I am positive that TextA has the number of
characters in it.

I also found this method on line. There were quite a few
examples but they were all quite old.

Krissco has an idea I am going to try in a few minutes and see
where it gets me.

Again, thanks for getting back to me!
 
G

Guest

Krissco;

Dim lthOfText as Integer

lthOfText = Len(Me!TextA) is how I counted the number of
Characters.

There are currently two Text Boxes, but I think I am going to
make it four.

Have to learn more about the application, I did not program this
English testing application.

I am going to try your idea in a little while. Thanks for getting back to me.

John
 
M

Marshall Barton

Just guessing here, but maybe you are suffering from a
misperception. There is no such thing as a "default font
size" for a report. The report's FontSize property is only
used by the Print method anf has no effect on any text
boxes. Note that using the Print method is a very advanced
way to display infomation in a report.

As both Kris and I are trying to point out, each text box
has its own properties that you have to set individually.
If you only have one data field that might be too long to
fit, then maybe you need to set just that one text box's
font size.

Since we can not see your report's arrangement, we're just
guessing at how that 10 year old code ever worked. From
where I sit, either 1) there is some very unusual techiques
being usedl 2) that code was not used to do what you want to
do now; or 3) you modified the old code in some way that
broke it. (Note that the code you posted would make a lot
more sense if the With statement used a text box instead of
the report object.
 

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