Calling Subprocedure problem
I created a class module to place a section of code in. The code reads the database and fills in a combobox with the records returned. I call the sub procedure from my form code by "Call mySP.FillSpecialPrograms", but the code hangs when it gets to the cboSpecProgs.Clear line. I receive a Run-time Error '424' Object required.
Any suggestions??
Here is the code for the sub procedure.
Public Sub FillSpecialPrograms()
Dim rs As New ADODB.Recordset
rs.Open "select * from regtb_specialprog", gcnData
cboSpecProgs.Clear <------This is where the code hangs.
cboSpecProgs.AddItem ""
cboSpecProgs.AddItem "Gifted/Talented"
cboSpecProgs.ItemData(cboSpecProgs.NewIndex) = -1
Do While Not rs.EOF
cboSpecProgs.AddItem rs("description")
cboSpecProgs.ItemData(cboSpecProgs.NewIndex) = rs("code")
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub
Re: Calling Subprocedure problem
I would assume that you need the form name added to the item description.
frmname.cboSpecProgs.Clear
Re: Calling Subprocedure problem
Basically cboSpecProgs has not been instantiated yet (as far as this procedure is concerned).
Re: Calling Subprocedure problem
On what line do you get the error? Did you try Stepping line by line to see what the problem might be?
Re: Calling Subprocedure problem
Hi,
zombie:
You need to pass the combobox to your class method so your sub declaration looks like:
Public Sub FillSpecialPrograms(ByVal cboSpecProgs As ComboBox)
and calling it:
obj.FillSpecialPrograms cboSpecProgs
Have a good one!
BK
Re: Calling Subprocedure problem
Thanks Pasvorto. That was the problem.
Re: Calling Subprocedure problem