|
-
Jun 20th, 2005, 10:46 AM
#1
Thread Starter
Addicted Member
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
-
Jun 20th, 2005, 10:51 AM
#2
PowerPoster
Re: Calling Subprocedure problem
I would assume that you need the form name added to the item description.
frmname.cboSpecProgs.Clear
-
Jun 20th, 2005, 10:51 AM
#3
Frenzied Member
Re: Calling Subprocedure problem
Basically cboSpecProgs has not been instantiated yet (as far as this procedure is concerned).
-
Jun 20th, 2005, 10:52 AM
#4
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?
-
Jun 20th, 2005, 10:54 AM
#5
Addicted Member
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
-
Jun 20th, 2005, 10:58 AM
#6
Thread Starter
Addicted Member
Re: Calling Subprocedure problem
Thanks Pasvorto. That was the problem.
-
Jun 20th, 2005, 01:08 PM
#7
Thread Starter
Addicted Member
Re: Calling Subprocedure problem
Last edited by zombie_man23; Jun 20th, 2005 at 03:37 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|