Set up a combobox to load a spring business list

3

I'm trying to load a combobox through the spring engines and the code I'm using to load the combobox is as follows:

Private Sub CommandButton1_Click()

Call ListasEmpresas

End Sub

Private Sub ListasEmpresas()

Dim MotorAdm As clsAdmMotor
Dim objEl As clsFichaEmpresa
Dim objEmp As clsFichaEmpresa

    Dim objCriador As AdmEngine900.clsCriaMotorAdm  'clsCriaMotorAdm
    Set objCriador = New AdmEngine900.clsCriaMotorAdm 'new clsCriaMotorAdm

   Set MotorAdm = objCriador.CriaMotorADM(0)

    For Each objEl In MotorAdm.Empresas
        'Set objEmp = MotorAdm.Empresas.Edita(objEl.Codigo)
       ComboBox1.AddItem = objEl.Codigo

        Set objEmp = Nothing
    Next

End Sub

But you are giving me this message:

What I'm missing from this component.

    
asked by anonymous 02.04.2018 / 11:11

1 answer

2

The error is in the way the object is loading.

Where is

ComboBox1.AddItem = objEl.Codigo 

It should be

ComboBox1.AddItem objEl.Codigo

You also do not need to be creating the administrator's engine. Below is a simpler version for listing companies.

Private Sub ListasEmpresas()

Dim objEl As clsFichaEmpresa

For Each objEl In PSO.Administrador.ListaEmpresas

  ComboBox1.AddItem objEl.Codigo

Next

End Sub
    
02.04.2018 / 14:36