RTF2 Control - Printing a Report throwing Property is Read-Only er

T

Toby Cundell

I have a problem with the RTF2 control in Access 2003. I used the example
database from the Lebans site by Andre Minhorst to split apart long text into
the series of paragrphs.

This works great in preview mode but throws a Property is Read-Only error
for every instance of the control on the page when you try to print the
report. I tried trapping this error through all the normal ways I know how
and I havent found a way to keep it from throwing the error. The report
DOES print correctly however. But it is unacceptable for the client to
have to click OK on an error box once for every paragraph to print a report.

The example database from the Lebans site (RTF00_1_5.mdb) has the same
problem when you try to print the paragraphs version.

Thank you very much in advance for any help!!!
 
S

Stephen Lebans

That error is generated if you try to read/write to the control before
it is fully instantiated. Youare probably trying to access the RTF2
control inthe Report's Open event. No ActiveX controls are fully
instantiated at that point on a reliable basis. Move your code to a
later event.

--

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

Toby Cundell

I only access the control in the detail_format area of code and that code
does not fire when the print button is clicked only when the form is loaded.
I have a test DB that has just the report and the table used to generate it
if you would like to see what I am seeing. Please email me an address to
send the file to my email address of tobsters777(at)hotmail(dot)com.

Thanks
Toby
 
T

Toby Cundell

As an update I removed the Detail_Format code and the preview of the form
doesnt work anymore but that does fix the printing problem. So it must
somehow fire the code in the Detail_Format during printing but apparently you
cant trap for it at that time. I put the code in the Detail_Print area and I
get an error that I cant change the height of a control while trying to
print. Long story short, I dont know where else to put the formatting code
so that it works.

Here is the Detail_Format code:

Private Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)

On Error GoTo err_Detail_Format
Dim Height As Integer
Me.RTFControl.Object.RTFtext = ""
Me.RTFControl.Object.RTFtext = Me.RTFParagraph
Height = Me.RTFControl.Object.RTFheight
If Height > 0 Then
If Height < 32000 Then
Me.RTFControl.Height = Height
End If
End If
Me.Section(acDetail).Height = Me.RTFControl.Height + Me.RTFControl.Top

If Me.RTFControl.Object.RTFheight > 0 Then
If Me.RTFControl.Object.RTFheight < 32000 Then
Me.RTFControl.Height = Me.RTFControl.Object.RTFheight
End If
End If
Me.RTFControl.RTFtext = Me.RTFControl.RTFtext


exit_Detail_Format:
Exit Sub

err_Detail_Format:
If Err.Number <> 2427 Then
MsgBox Err.Description
End If
Resume exit_Detail_Format

End Sub

The form is set to read data from a table.

Thanks
 
S

Stephen Lebans

You cannot resize controls, any controls, in the Print event. You must
use the Format event as my sample code shows.

What is the line of code that is causing the error?

--

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

Toby Cundell

I know I cant do that in the Print, but I gave it a shot just to eliminate
all the possibilities...

What line does it occur in? See thats the whole problem. I can step-trace
the detail_format code during the report opening for preview but I cant step
through during the actual printing.

Further testing shows that the detail_format code is executing during the
print phase because I inserted a msgbox into the code and it displays the
dialogs while printing along with the errors. I turned off my error trapping
dialog and the errors still show up so there is an error being triggered in
and being displayed in the control itself.

I guess what I am asking is there a way to tell the control not to display
errors in certain circumstances? It DOES print the document correctly so the
formatting is working during printing (or I guess its leftover from
previewing??) but the control throws an error anyway. More of an annoyance
bug than anything. Due to the nature of the formatting routine, a 10
paragraph printout will generate 25 error dialogs.

BTW, the error dialogs are formatted like this: title = RTF2, Big Red X
Icon, text = Property is read-only.

Let me know if that explains it better.

Thanks
Toby
 
S

Stephen Lebans

Please post all of your code behind the report. Do not leave anything
out.

--

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

Toby Cundell

The code I posted for the Detail_Format is the only code behind the report
save two commands... in the Report_Open it does a docmd.Maximize and in the
Report_Close it does a docmd.Restore for display purposes. I tried removing
those (better safe than sorry) just to be absolutely sure and it doesnt fix
the problem.
 
T

Toby Cundell

Also, if you would like me to send you a test db with just the table (and
data) and the report in question, please email me at the address I posted
earlier and I can get you a copy to poke at.

Thanks in advance for your help...

Toby Cundell
 
S

Stephen Lebans

Send it to
Stephen at lebans.com
Replace at with @
--

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

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