Solved

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

Posted on 2006-11-21
1
2,958 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 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

13 Experts available now in Live!

Get 1:1 Help Now