Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX component can't create object 1

Status
Not open for further replies.

NeilFrank

Programmer
Mar 12, 2000
167
CA
I have just reinstalled a VB6 app I have developed on a Windows XP machine and it is crashing at a point that had previously been OK for many years running in XP.

This involves a third party graphing utility called the Flipper Graph Control I have inserted the pertinent section from the manual:

"Sending ADO Recordsets to Flipper Graph Control
Flipper Graph Control achieves database interaction through fairly passive means. Essentially, you use ADO to set up the connection and the Recordset then pass it to Flipper. We use an intermediate object, FlpGrfADO, to receive and read the Recordset. Then the FlpGrfADO object is passed to Flipper Graph Control and the Recordset information is placed into the Graph Control's internal data buffer. There is no link or connection to
the database or Recordset data saved by Flipper Graph Control or the FlpGrfADO object. Therefore, if the data in the database or Recordset is modified you will have to resend the data to Flipper. Also, when the data is sent to Flipper Graph Control via FlpGrfADO the old data in the data buffer will be overwritten by the new data.
However, if there are more row and columns in the internal data buffer than in the Recordset then the excess rows and columns will not be affected."

Here is the relevant code:

Dim flpData As New FLPGRFADOLib.FlpADO

'Send RS to flpData
'This is the line that gives me the runtime error
'grsTempGraphChronMedTable links to an MS Access table
flpData.Recordset grsTempGraphChronMedTable

When I search the TekTips form on "ActiveX component can't create object", I get several hundred posts, but I'm not sure how to narrow these down to VB6.

Any suggestions?

Thanks!!
 
This line:
Code:
Dim flpData As New FLPGRFADOLib.FlpADO
"arms" the object for creation when first touched.

This line:
Code:
flpData.Recordset grsTempGraphChronMedTable
is failing trying to create the instance of your FLPGRFADOLib.FlpADO object.

My guess is the library is missing, not registered, or is missing a license.
 
Thanks, dilettante. All of the above are OK.

The search continues!
 
NeilFrank said:
All of the above are OK.

How have you verified that?

I would test by replacing your line of code with whatever is the simplist property of the object, e.g. something like:

Debug.Print flpData.Caption

If the error still occurs, then your class is not properly registered. If the error goes away, then something inside the Recordset property/method is using an object that is not properly installed.
 
If I am not mistaken, then this line:
Code:
Dim flpData As New FLPGRFADOLib.FlpADO
defines the variable and reserves the stack for it but does not really initialise it, which is why, when it reaches this point:
Code:
flpData.Recordset grsTempGraphChronMedTable
the flpData object is not properly initialised, hence fails.

Instead, do it like this:
Code:
Dim flpData As [red][s]New[/s][/red]FLPGRFADOLib.FlpADO

[b]Set flpData = New FLPGRFADOLib.FlpADO[/b]
flpData.Recordset grsTempGraphChronMedTable

Good luck!
MakeItSo

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
>does not really initialise it

However, any mention in code to the object will cause it to initialise if it is not already initialised.
 
I just googled a bit and this explains better what I meant:
When you declare a variable Dim X As New ..., Visual Basic doesn't actually initialize the variable until it uses it. Every time you refer to the variable Visual Basic needs to see if the variable has been initialized and initialize it if it hasn't. It essentially does something like this:

If X Is Nothing Then allocate X
Now do what the program says

The idea is Visual Basic cannot really know apriori whether the variable has been allocated yet.

If you declare the variable and initilize it separately, Visual Basic assumes you know what you're doing and that you will allocate the variable before you use it. If you don't, it raises an error.

That is what I meant: the initialisation is not fully persistent. However, although it slows down the code execution, it should not create an ActiveX error, or should it?
[ponder]

@Neil: does the "Set ..." statement remove the error?

Besides: shouldn't this line
Code:
flpData.Recordset grsTempGraphChronMedTable
rather read something like this?
Code:
Set flpRS = flpData.Recordset(grsTempGraphChronMedTable)
??

Does the recordset method of flpData open a recordset and hold it in flpData, or does it create a recordset object which needs to be assigned to a FlpGrfADO Recordset variable?
[ponder]


[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
>When you declare a variable Dim X As New

That's what I said ...

> it should not create an ActiveX error

Correct
 
>Besides: shouldn't this line
>rather read something like this?

Not according to the Flipgraph documentation.

But here's a quick question to the OP: are you sure that grsTempGraphChronMedTable is actually a valid ADO recordset at this point? How is it declared and populated?

 
VERY much appreciate all your suggestions and comments. In response:

flpdata has only one property, the .Recordset


Replacing
Dim flpData As New FLPGRFADOLib.FlpADO

with
Dim flpData As FLPGRFADOLib.FlpADO 'Line 1
Set flpData = New FLPGRFADOLib.FlpADO 'Line 2
flpdata.Recordset grsTempGraphChronMedTable 'Line 3
[ or flpdata.Recordset (grsTempGraphChronMedTable)]

only serves to shift the run-time error from Line 3 to Line 2


The TempGraphChronMed Table (3 Fields/238 Records) is created - for the purposes of tracking down this bug - at design time.

I use the following code to populate the Recordset:

Public gcnGraph As ADODB.Connection
Public grsTempGraphChronMedTable As ADODB.Recordset

Public Sub EstablishPsychEMRDatabaseConnection()
Set gcnGraph = New ADODB.Connection
gcnGraph.ConnectionString = _
"Provider = Microsoft.Jet.OLEDB.4.0; Data Source= " & App.Path & "\Graph.mdb"
gcnGraph.CursorLocation = adUseClient
gcnGraph.Open
End Sub

I can confirm that it is a valid Recordset at runtime:
With grsTempGraphChronMedTable
.MoveFirst
Do While Not .EOF
MsgBox .Fields.Item(0).Value
.MoveNext
Loop
End With

One other comment. I make use of analogous Recordsets throughout my app and all appear to be functioning. The problem has something to do with the 3rd party Flipper Graph control. I have had multiple discussions with tech support, who has provided me with a test app which works on their (Windows Vista now and Windows XP in the past) machines. This app gives the identical run-time error 429 when I run it on my Windows XP machine. [Note this machine, an old Dell Dimension 4600, ran my app and the Flipper Graph code for years, but after I was obliged to reformat its hard drive and reinstall XP, this bug now pops up.] I have re-registered the relevant .ocx and .dll files, to no avail. It is the opinion of tech support that I am "in dll hell."
 
>only serves to shift the run-time error from Line 3 to Line 2

That bit of info made the question about the recordset redundant.

So we are definitely down to it being a problem with the Graph Control ...

> I have re-registered the relevant .ocx and .dll files

Have you checked the dependencies?
 
I installed and ran Dependency Walker, and then followed the following directions from the FAQ:

"The best way to debug a module that fails to register is by opening REGSVR32.EXE in Dependency Walker rather than your DLL. Then choose to start profiling (F7). In the profiling dialog, enter the full path to your DLL in the "Program arguments" field. For "Starting directory", you may wish to enter the directory that the DLL resides in. Check the options you wish to use and press Ok. This will run REGSVR32.EXE and attempt to register your DLL. By actually running REGSVR32.EXE, you can see more types of runtime errors."

I am VERY happy - albeit more than a little mystified - to report that this solved my problem!!!!!

strongm, you are THE BEST!!!!!!!!!!!!!!!!!!!!!!!!!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top