Solved

VB6 - Compile Error - "Object does not source automation events"

Posted on 2006-11-21
1
2,945 Views
Last Modified: 2013-11-25
This is on a VB 6 project that I've had working for years and have added to from time to time.  Well, now, all of a sudden, I'm getting a compile error on a simple entry screen as follows:

(Partial code for screen follows)
-------------------------------------------------------------------
Dim WithEvents adoPrimaryRS As Recordset   <== ERROR HERE WITH "Object does not source automation events"
Dim mbChangedByCode As Boolean
Dim mvBookMark As Variant
Dim mbEditFlag As Boolean
Dim mbAddNewFlag As Boolean
Dim mbDataChanged As Boolean

Private Sub Form_Load()
    Dim db As Connection
    Set db = New Connection
    db.CursorLocation = adUseClient
    db.Open "PROVIDER=MSDASQL;dsn=SWSREParams;uid=;pwd=;database=BizParams.txt;"
   
    Set adoPrimaryRS = New Recordset
    adoPrimaryRS.Open "select DataBaseName,DSNName,ArchiveDBName,ActiveFileLocation,ArchivedFileLocation,DefaultName from BizParams.txt", db, adOpenStatic, adLockOptimistic
   
    Set txtDataBaseName.DataSource = adoPrimaryRS
    Set txtDSNName.DataSource = adoPrimaryRS
    Set txtArchiveDataBaseName.DataSource = adoPrimaryRS
    Set txtActiveFileLocation.DataSource = adoPrimaryRS
    Set txtArchivedFileLocation.DataSource = adoPrimaryRS
    Set txtDefaultName.DataSource = adoPrimaryRS
   
    mbDataChanged = False
End Sub
---------------------------------------------

I think this MAY be related to References and/or Components; but I cannot locate the problem.  AND, as far as I know, I've made no changes to them right before this started!  Anyway, ALL References and Components included -- in order listed inside the Project -- are:
______________________________________________________________

REFERENCES:
Visual Basic for Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
Crystal Report Viewer Control
Crystal Report 8 ActiveX Designer Run Time Library
Crystal Report 8 ActiveX Designer Design Time Library
Crystal ActiveX Query Viewer 1.0 Type Library
Crystal Report 8 Standard Wizard Library
Crystal Report Engine 8 Object Library
Crystal Report Export
Crystal Report Viewer Control
Crystal Reports 8 Library
Crystal Data Object
cryptext 1.0 Type Library
Microsoft Management Console 2.0
Microsoft Internet Controls
Microsoft Data Report Designer 6.0 (SP4)
Microsoft Data Source Interfaces
Microsoft DAO 3.6 Object Library
COM+ Services Type Library
Microsoft Data Formatting Object Library 6.0 (SP6)
Microsoft Data Binding Collection VB 6.0 (SP4)
OLE Automation
Microsoft OLE DB Simple Provider 1.5 Library
Microsoft OLE DB Service Component 1.0 Type Library
Microsoft ActiveX Data Objects 2.8 Library


COMPONENTS:
Crystal ActiveX Query Viewer 1.0 Type Library
Crystal Report Control
Crystal Report Viewer Control
Crystal Select Expert OLE Control Module
Microsoft ADO Data Control 6.0 (SP6) (OLEDB)
Microsoft Common Dialog Control 6.0 (SP6)
Microsoft DataGrid Control 6.0 (SP6) (OLEDB)
Microsoft DataList Controls 6.0 (SP6) (OLEDB)
Microsoft Internet Controls
Microsoft Masked Edit Control 6.0 (SP3)
Microsoft PictureClip Control 6.0 (SP3)
Microsoft Rich Textbox Control 6.0 (SP6)
Microsoft Tabbed Dialog Control 6.0 (SP6)
Microsoft Windows Common Controls 6.0 (SP6)
Microsft Windows Common Controls-2 6.0 (SP6)
____________________________________________

ANY help would be GREATLY appreciated and will get me off top dead center!  Thanks in advance for your help!

estewb

PS:  I forgot to note that even if I comment out the offending line on that entry screen, it occurs on other entry screens that are very similar in the Project!

0
Comment
Question by:estewb
1 Comment
 
LVL 4

Accepted Solution

by:
JRCSystems earned 125 total points
ID: 17992568
Heres the answer: Change the order/priority of the references.

You have BOTH DAO and ADO references, and according to your list, it references DAO first, which does not fire events.

If you are NOT using DAO, drop the reference.

If you are using both, be SURE to set the correct priority,

AND to be safe...

I would declare the variables as
Dim poRS    As DAO.Recordset
or
Dim poRS    As ADO.Recordset

etc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now