I am adding a usercontrol combo box to another usercontrol form and when I do this the program actually runs and goes to an initialise routine in a class and shows the error mentioned in subject.

I have a collection of records and a new combo box and this is the reason also for the new class. The routine in the new class has a 'For' loop, which adds the items to the combo box and this is where the error shows up.

My main question is why does the code start running when I try to add a user control to the main parameter user control form?

Thanks

Andrew

Your question is a bit vague. It seems that you are either calling the function when adding the control, or your function is related to that TYPE of control, hence running the function as soon as a control is added.

This much I could gather. Add a bit more on the error or post some code, or be a bit more specific about which control etc, and we will gladly assist.

Your question is a bit vague. It seems that you are either calling the function when adding the control, or your function is related to that TYPE of control, hence running the function as soon as a control is added.

This much I could gather. Add a bit more on the error or post some code, or be a bit more specific about which control etc, and we will gladly assist.

Ok Thanks

Here is a bit more details from VB forums:

I have created a new class and a cache of records for a list of details for a dropdown box. The dropdown box is a usrcontrol and it is displaying ok but I have a problem with the error:

438 object doesn't support this property or method

when the form is called from the main menu; everything else works ok on the menu.

My code is failing here, the initialize sub that is in the new user control combo box code:

'**
'Populate the combo box with records from cache
Private Sub UserControl_Initialize()
    Dim al As RecordType
    Set mvarRecordType = Nothing
    UserControl.cmbRecordType.Clear
    For Each al In CacheRecordTypes [B]<<< Fails here[/B]
        cmbRecordType.AddItem al.RecordDescription
    Next
End Sub

I have created the new cache, that seems to populate with the correct records, as I debugged that, from this point it would go to the enumeration pointer for the collection of records but it does not even get this far before failing at the initialize sub.

Another thing is that when I take the new usrcontrol combobox I created and try and put it the other usrcontrol, which is called controlparameters (this has fields and combos on it) I get the error I was talking about (even though I am not running it.)

To confirm I did copy the code for the enum and rename the parts I needed to to reflect the new class.

'**
'retrieve enumeration interface pointer for the collection
'@rem          Tools->Procedure Attributes->Advanced - Hide this member and
'Procedure ID = -4
'@return       IUnknown.
Public Function NewEnum() As IUnknown
    Set NewEnum = mRecordTypes.[_NewEnum]
End Function

The cache is declared as follows in main.bas:

Public Declare Function HtmlHelp Lib "HHCtrl.ocx" Alias "HtmlHelpA" _
                                 (ByVal hWndCaller As Long, _
                                  ByVal pszFile As String, _
                                  ByVal uCommand As Long, _
                                  dwData As Any) As Long

-----------------
Public CacheRecordTypes As New RecordTypes
-----------------

Then function to retrieve records is called

Public Sub InitiliseCache
----------
CacheRecordTypes.RetrieveRecords
----------
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.