demoman,
This is what's happening:
1 - You cannot use the methods of class on an object of a different class. In your case, you are using the methods of the Adodc class (Recordset, for instance) on an object of the Control class, and this is not allowed. Recordset is a method of the Adodc class and thus you must use it with an object of the Adodc class. That's why you get the error
"object does not support this property or method". Let's look at your function again:
Code:
[COLOR=blue]Public Sub[/color] Load_Data_Values(objAdo [b][COLOR=blue]As[/color] Control[/b])
[COLOR=green]' You cannot do this because objADO is a
' Control object, not an Adodc one[/color]
x.Text = objAdo.[b]Recordset.Fields!Field1[/b]
...
[COLOR=blue]End Sub[/color]
2 - In your function, the parameter should be of type Adodc. Now, when you use the Adodc class, things should work properly, but you have to call the
Refresh method of the control to populate the recordset before you use it. Thus, your code should look like this:
Code:
[COLOR=green]' Note that objADO is of type Adodc[/color]
[COLOR=blue]Public Sub[/color] Load_Data_Values(objADO [b][COLOR=blue]As[/color] [COLOR=darkred]Adodc[/color][/b])
[COLOR=green]' Use Refresh to populate the recordset[/color]
[b]objADO.Refresh[/b]
[COLOR=green]' This (below) should work fine[/color]
x.Text = objADO.Recordset.Fields!Field1
...
[COLOR=blue]End Sub[/color]
Make sure that you use the name of the fields correctly. For example, for the line where it says objADO.Recordset.Fields
!Field1, the recordset must have a field called Field1, otherwise the code won't work either. Thus, if your connection string is accessing a table or query that contains a field called "CustomerID", then the line above should be objADO.Recordset.Fields
!CustomerID.
Hope this helps!
JC
Friends are angels who lift us to our feet when our wings have trouble remembering how to fly...