Re: RTF2 Control - Printing a Report throwing Property is Read-Onl

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Toby Cundell (TobyCundell_at_discussions.microsoft.com)
Date: 03/17/05


Date: Wed, 16 Mar 2005 22:43:05 -0800

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

"Stephen Lebans" wrote:

> 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.
>
>
> "Toby Cundell" <TobyCundell@discussions.microsoft.com> wrote in message
> news:C3127BB7-A67D-43CF-B772-9D040947FAB7@microsoft.com...
> > 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
> >
> >
> >
> > "Stephen Lebans" wrote:
> >
> > > 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.
> > >
> > >
> > > "Toby Cundell" <Toby Cundell@discussions.microsoft.com> wrote in
> message
> > > news:D010BFE6-3801-45F4-88B5-9C67B3183153@microsoft.com...
> > > > 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!!!
> > > >
> > >
> > >
>
>



Relevant Pages