Stephen Lebans follow-up question

A

Al

Stephen,
I posted this reply in the wrong newsgroup before I left
on vacation last week. I have been deperately trying your
suggestion below but I haven't had any luck. I don't
understand the reference to "the control's RTF property."
I'm still a novice on the VBA side of Access and would
greatly appreciate your advice on how to accomplish this.
I assumed that the control referred to is a Richtext box
but I don't understand the RTF property.
Our correspondence from a previous post is listed below.
TIA,
Al
----------------

You cannot do this in a Report at runtime, period. To get
around it you will have to programmatically set the
control's RTF property instead:
1) Read the disk based TextFile into a string
2) Set the control's RTF property during the section's
event housing the control.

HTH
Stephen Lebans
http://www.lebans.com

I just tried the code on the Form_Open event and it worked
fine. Is there a method I can use on the Report_Open
event? I think that's where the problem is.
TIA
Al
-----Original Message-----
If you are using the MS Rich Text ActiveX control then the
code I posted will work. What control are you using?

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

Thank you for your reply, Stephen. I tried that and got
the following error: Run-time error '2771' The bound or
unbound object frame you tried to edit doesn't contain an
OLE object.
Any ideas?
Al

-----Original Message-----
The correct syntax would be something like:
Me.RichText1.OBject.Filename = "C:\Filename.rtf"

HTH
Stephen Lebans
http://www.lebans.com

I have a basic question that I can't seem to find an
answer to anywhere... How do you load a file into a
RichText Box using Access 2000? I have tried the method I
found on different news groups:
RichText1.Loadfile "FileName.rtf"
This does not work and generates Run-time error '438'
Object doesn't support this property or method.
Is .Loadfile only accepted in VB and not VBA? Do I need
to add a Common Dialog Control?
Any help to point me in the right direction would be
greatly appreciated.
TIA,
Al
 
A

Al

Thanks Dirk,
I gave it a try and kept getting "The OpenReport action
was cancelled." Then, after moving things around to the
following:

Dim mstrRTFText As String ' declared at module level

Private Sub Detail_Format(Cancel As Integer)
Dim Pth As String
Dim intFileNo As Integer

' Get rich text from file -- this would be done at the
' Detail level if the file varies from record to record.
Pth = [Forms]![frmWord].Report

intFileNo = FreeFile()

Open Pth For Input As #intFileNo
mstrRTFText = Input(LOF(intFileNo), intFileNo)
Close intFileNo

Me!IRep.rtf = mstrRTFText

End Sub

I got the error: The expression On Format you entered as
the event property setting produced the following error:
Procedure declaration does not match description of event
or procedure having the same name.

Thanks again for your help,
Al
 
A

Al

Dirk,

I'm sorry, that was my mistake. I forgot to put the
declaration in there; you had it in your original code.
However, even with that in there I am getting the error:
Run-time error '438' Object doesn't support this property
or method. It is referring to ".rtf" in the
line "Me.IRep.rtf = mstrRTFText"

Thank you very much for your help,
Al
-----Original Message-----
Al said:
Thanks Dirk,
I gave it a try and kept getting "The OpenReport action
was cancelled." Then, after moving things around to the
following:

Dim mstrRTFText As String ' declared at module level

Private Sub Detail_Format(Cancel As Integer)
Dim Pth As String
Dim intFileNo As Integer

' Get rich text from file -- this would be done at the
' Detail level if the file varies from record to record.
Pth = [Forms]![frmWord].Report

intFileNo = FreeFile()

Open Pth For Input As #intFileNo
mstrRTFText = Input(LOF(intFileNo), intFileNo)
Close intFileNo

Me!IRep.rtf = mstrRTFText

End Sub

I got the error: The expression On Format you entered as
the event property setting produced the following error:
Procedure declaration does not match description of event
or procedure having the same name.

Thanks again for your help,
Al

Ah, that's because I didn't have the opportunity to check my air code,
and I gave you an incorrect declaration for the Detail_Format procedure.
It should be this:

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

That should get you past that error, at least.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
D

Dirk Goldgar

Al said:
Dirk,

I'm sorry, that was my mistake. I forgot to put the
declaration in there; you had it in your original code.

I think I had it wrong in my code, as I wrote that without reference to
an actual report.
However, even with that in there I am getting the error:
Run-time error '438' Object doesn't support this property
or method. It is referring to ".rtf" in the
line "Me.IRep.rtf = mstrRTFText"

I'm not all that familiar with the Rich Text Control, but maybe Stephen
made a mistake (for once). Try this:

Me.IRep.TextRTF = mstrRTFText
 
S

Stephen Lebans

All I am currently on vacation and my WIn2K development machine is toast
thanks to MS Automatic Updates! IF you can wait for a week send me an
EMail late next week and I'll see if I can work something out for you.

--

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

Dirk Goldgar

Stephen Lebans said:
Nice routine Dirk. Thanks!

Thanks, Stephen. Only trouble is, it doesn't work. Even after
modifying it to refer to the TextRTF property, I can't seem to get it to
let me assign to the property.
 
D

Dirk Goldgar

Al said:
Thanks Dirk,
I tried that and did not get an error message but the file
will not populate the Richtext box. The Report opens with
the linked records and nothing in the Richtext control.
I can't understand why the .LoadFile works perfectly for
this task with Forms but not with Reports. I have found
instances in other newsgroups where other forlorn users
have had similar problems and no one was able to help them
either.
I've been trying an inserted Word object or a plain text
box to import this file too, but I haven't had any luck
with those either.
I guess its back to the drawing board...
Thanks for all your help,
Al

I can't seem to get it to work either. May I suggest you forget about
the Microsoft Rich Textbox Control and use Stephen Lebans' RTF2 control
( http://www.lebans.com/richtext.htm )? You may have better luck with
that.
 

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