PDA

Click to See Complete Forum and Search --> : Calling my ActiveX Sub


David Laplante
Oct 31st, 1999, 01:44 PM
I Have a procedure in an activex control that when I try to call I get and "Object required" error... any ideas?

Here's the code

Activex sub:

Public Sub Repopulate()
Dim DB As Database
Dim rstRecordSet As Recordset
Dim Entete As String
Dim Data As String
Dim I As Integer

Set DB = TechGrid.dsDatabase
Set rstRecordSet = DB.OpenRecordset(TechGrid.dsRecordset, dbOpenSnapshot)

Flexgrid.Rows = 2
Flexgrid.Cols = rstRecordSet.Fields.Count
Flexgrid.FixedRows = 1

'Faire les entetes de colonnes...
For I = 0 To rstRecordSet.Fields.Count - 1
If I = 0 Then
Entete = rstRecordSet.Fields(I).Name
Else
Entete = Entete & Chr(9) & rstRecordSet.Fields(I).Name
End If
Next I

'Populer la grille
rstRecordSet.MoveFirst
Do While Not rstRecordSet.EOF
For I = 0 To rstRecordSet.Fields.Count - 1
If I = 0 Then
Data = rstRecordSet.Fields(I).Value
Else
Data = Data & Chr(9) & rstRecordSet.Fields(I).Value
End If
Next I
Loop
End Sub


Now I call my procedure as so:

TechGrid1.Repopulate

Please Help.

SteveS
Oct 31st, 1999, 02:25 PM
Are you calling the Sub from a seperate Program with an instance of the OCX in the Program.

If so it should work, I think.

Try creating a group project, by opening the Active Project and adding a project to it.

This will allow you to see exactly what line the error is occuring on, maybe the object required is within the OCX. This method will allow you to debug the OCX.

Hope this helps,

Steve.

David Laplante
Oct 31st, 1999, 07:22 PM
Thank you very much.... I'l try that!

webman
Nov 1st, 1999, 01:50 AM
If your app is an ActiveX DLL, then from the second program you need to get a handle to the first program.

Example

Dim MyGrid

Set MyGrid = CreateObject("objectname.classname")

MyGrid.Repopulate

The project group is a good way to test, but it more tightly couples the objects, making it harder to deliver updates.

------------------
WebMan

David Laplante
Nov 1st, 1999, 08:07 AM
HEHE... you kinda lost me there Webman...

What I'm trying to do is an activex that I can use in a .exe just as I would use msflexgrid. My activex has MsFlexGrid in it. I just want to be able to use mine without as easly as say a listbox in MsAccess Where I would just have to set it's recordsource (a property) and then call the repopulate method.

can u help

P.S.: I tried what you said SteveS but the debugger wouldn't go in my activex code.