borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (export ms access to ms excel sheet)Next Topic (run code on save) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : [b]Help using RichtextCtrl in Access 2003[/b]
Poster Message
mosheeps
Level: Graduate

Registered: 20-08-2006
Posts: 9

icon [b]Help using RichtextCtrl in Access 2003[/b]

Hi.

I have a VBA problem and I hope somebody in this forum can help me.

I received recently an Access 2000 application, which mainly displays an ".rtf" file, according to the value of a chosen record (focused on screen).

The display control/variable is defined as:

Name: RtfCMMI
Class: RICHTEXT.RichtextCtrl.1
OLEClass: RichtextCtrl

Even though the RICHTX32.ocx control is registered OK, in Access 2003 I get:

"Runtime error 438: Object doesn't support this property or method"

for the "LoadFile" command, everytime I try to run the application.

The routine used to display the file is as follows:


Private Sub Load_CMMI_File() 'Activates the RTF box with the Process Area with focus at at top of document
    Dim FLoc As String          'File full path
    Dim FName As String         'File name (including extension)
    Dim strSearch As String
    
    FLoc = Left$(CurrentDb().Name, Len(CurrentDb().Name) - Len(Dir$(CurrentDb().Name))) + "pa_doc\"
    FName = lstPA.Column(1) + ".rtf"
    
    RtfCMMI.SetFocus 'the CMMI-Text becomes the active window
    RtfCMMI.LoadFile (FLoc + FName)
    RtfCMMI.UpTo Chr(0), False  'set cursor and scrollbar to begin of file
End Sub

Can anyone please help me solve this problem?

TIA


____________________________
TIA

MosheEps

Software, SQA, ISO/CMMI,

Integration & Testing Engineer

20-08-2006 at 06:51 PM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi,
Try removing the brackets from the call

as in:
RtfCMMI.LoadFile FLoc & FName

Also
check that "floc+fname" creates a proper file path.

Hope this helps,
Kieron

PS. I don't have acc2k at home, so cannot verify this solution.


____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

27-08-2006 at 10:21 AM
View Profile Send Email to User Show All Posts | Quote Reply
mosheeps
Level: Graduate

Registered: 20-08-2006
Posts: 9
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Thanks - I tried it; even defined another variable containing "(FLoc + FName)" and it stil didn't work.

Somebody in another forim told me that this control doesn't work in Access 2003. Is it true? If so - how can I bypass this problem?

____________________________
TIA

MosheEps

Software, SQA, ISO/CMMI,

Integration & Testing Engineer

27-08-2006 at 05:04 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Help using RichtextCtrl in Access 2003

Hi,
I don't know about Access 2003, but it works in 2002 (XP)
When you say that the control is registered OK do you just mean that it is registered with Windows, or is it registered within your Access Project. If you go into the VBA code window and select Tools/References it should be ticked in that list. If it is, are you sure that it is the same version, it is quite possible that the original project used an earlier version (probably V.5 and you will probably have V6 loaded).
If all that is OK then it could be that you have not specified the file type to load, which is the second arguement for the LoadFile call :-

Me.RtfCMMI.LoadFile FLoc & FName, rtfText



[Edited by GeoffS on 28-08-2006 at 08:23 AM GMT]

____________________________
multi-tasking - the ability to hang more than one app. at the same time.

28-08-2006 at 08:21 AM
View Profile Send Email to User Show All Posts | Quote Reply
mosheeps
Level: Graduate

Registered: 20-08-2006
Posts: 9
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Thanks.

The control is registered both with Windows and within the project.
Anyway, I tried to downgrade it from V6 to V5 and stil it didn't work.
I also tried the second (optional) parameter for the load command and stil got the same error.
Any more ideas anyone?


____________________________
TIA

MosheEps

Software, SQA, ISO/CMMI,

Integration & Testing Engineer

28-08-2006 at 10:29 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Help using RichtextCtrl in Access 2003

Hi,
I do know that Access can get a bit sniffy with ActiveX Controls, particularly if you copy a Control from one Form and paste it to another, or if you copy a whole form.
Try deleting the Control on your Form, then Save the Form and Close it. Close the project and then Access completely to flush anything it may have in memory. Re-open and add a brand new control to the Form, not forgetting to give it the name you have in Code.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

28-08-2006 at 02:47 PM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi,
I just tried the following (with accessXP)
Dim s As String
Dim fin As Integer
fin = FreeFile
Open "c:\testrtf.rtf" For Input As fin
s = Input(LOF(fin), fin)
Close

    With Me.RichTextBox0
        .Value = s
    End With
    
and it worked... is AccessXP the same as 2003?
Kieron


____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

28-08-2006 at 09:50 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi Kieron,
Access XP is Version 10 (2002) - Access 2003 is Version 11 - but as far as I am aware apart from some additional support for DotNet and XML it is much the same. Certainly it should handle the RichTextBox control in the same way as it is an external ActiveX Control, and whilst your method will certainly get the contents of the file into the control you should not have to do it that way - "RichTextBox0.LoadFile" SHOULD work.
    

____________________________
multi-tasking - the ability to hang more than one app. at the same time.

29-08-2006 at 08:08 AM
View Profile Send Email to User Show All Posts | Quote Reply
mosheeps
Level: Graduate

Registered: 20-08-2006
Posts: 9
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi, GeoffS.

I already tried deleting the control and building the form from scratch but it stil didn't work.

Are you sure this control works in Aceess 2K3? I'm beginning to believe it doesn't and I'm stuck with this application that I stil need.


____________________________
TIA

MosheEps

Software, SQA, ISO/CMMI,

Integration & Testing Engineer

30-08-2006 at 12:56 PM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi MoS,
I note you're only using the LoadFile.. have you tried the code I uploaded too?
K


____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

30-08-2006 at 09:14 PM
View Profile Send Email to User Show All Posts | Quote Reply
mosheeps
Level: Graduate

Registered: 20-08-2006
Posts: 9
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi, K.

I'm not using only Load. Before this command I have "SetFocus" and after that I have also "UpTo" (see original post - code section).

Any more ideas?


____________________________
TIA

MosheEps

Software, SQA, ISO/CMMI,

Integration & Testing Engineer

31-08-2006 at 10:15 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi,
I notice that you have a reference in the Floc variable to "CurrentDb()." This is a DAO reference, which is not set in the references of Access after version 8 (97), as the default data access method is ADO. Have you set a reference to DAO3.6  

____________________________
multi-tasking - the ability to hang more than one app. at the same time.

31-08-2006 at 06:44 PM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Apologies,
I was obviously unclear, I'll rephrase.

I note that you are using the LoadFile command. Have you also tried the value command and did it have the same issues.

Kieron

PS. I had also noted that you used other words [edited]

____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

31-08-2006 at 11:59 PM
View Profile Send Email to User Show All Posts | Quote Reply
mosheeps
Level: Graduate

Registered: 20-08-2006
Posts: 9
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi, GeoffS.

I've got both DAO3.6 and ADO 2.8 and it stil does'nt work.

Hi, Kieron.

I've tried other commands and stil get the same error.
  

____________________________
TIA

MosheEps

Software, SQA, ISO/CMMI,

Integration & Testing Engineer

03-09-2006 at 12:04 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]


Then it SHOULD be working.
Just a thought - the RichTextBox Control is an ActiveX component, it is not a standard control with MS Access. It may well be present on your PC but unless it has been installed as part of the VB6 Setup then it may not be registered for using under development scenarios. What are the circumstances under which this control was installed on your PC

____________________________
multi-tasking - the ability to hang more than one app. at the same time.

03-09-2006 at 01:03 PM
View Profile Send Email to User Show All Posts | Quote Reply
mosheeps
Level: Graduate

Registered: 20-08-2006
Posts: 9
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi, GeoffS.

I don't remember when it was installed. Anyway, after receiving the application, I reinstalled it and made sure it's registered under Access.
  

____________________________
TIA

MosheEps

Software, SQA, ISO/CMMI,

Integration & Testing Engineer

04-09-2006 at 08:33 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi mosheeps,
When you say you "reinstalled" it - how did you do that. Simply registering the control with Windows (by using Regsvr32 or the setup file that came with your Access 2000 App.) only allows the control to run on your machine. To use it for development you must be Licensed, so it must be installed as part of a VB6 installation or similar, otherwise you will not e able to develop with it.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

04-09-2006 at 08:39 AM
View Profile Send Email to User Show All Posts | Quote Reply
mosheeps
Level: Graduate

Registered: 20-08-2006
Posts: 9
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi, GeoffS.

It was installed probably with the VB6 environment or the .NET framework.

Anyway: after it didn't work, I reinstalled it using the setup inf that came with the application. And when it stil didn't work, I rolled back to my original installation and it stil doesn't work.

To tell you the truth, I'm starting to believe it doesn't work under Access 2003 and I don't know what to do with it. Any more suggestions
  

____________________________
TIA

MosheEps

Software, SQA, ISO/CMMI,

Integration & Testing Engineer

07-09-2006 at 08:38 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: [b]Help using RichtextCtrl in Access 2003[/b]

Hi mosheeps,
Read my last post carefully. If you have installed this control by using the setup that came with the user application then you do not have development rights for this control, which is why you cannot get your code to work. You must install VB6 onto your PC for the control to be installed with developer rights. Then it will work.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

09-09-2006 at 12:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : [b]Help using RichtextCtrl in Access 2003[/b]
Previous Topic (export ms access to ms excel sheet)Next Topic (run code on save) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder