Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

types and classes

Status
Not open for further replies.

nigz

Programmer
Jun 15, 2001
60
GB
Hi - I want to use the following type in a class - but I can't seem to get the syntax right. VB6 won't let me declare a public variable of type FormRecordsets and the following code, although it doesn't fall over doesn't work either. I would be grateful of any pointers, thanks!

Public Type FormRecordsets
rec4dbcOrgName As ADODB.Recordset
rec4dbcRole As ADODB.Recordset
rec4dgdMain As ADODB.Recordset
End Type

Public Property Let udtFormRecordsets(vData As FormRecordsets)
mvarudtFormRecordsets = vData
End Property


Public Property Get udtFormRecordsets() As FormRecordsets
udtFormRecordsets = mvarudtFormRecordsets
End Property

Regards

Nigel

 
I think that:

Code:
Public Type FormRecordsets
    rec4dbcOrgName As ADODB.Recordset
    rec4dbcRole As ADODB.Recordset
    rec4dgdMain As ADODB.Recordset
End Type

Private mudtFormRecordsets As FormRecordSets

Public Property Let udtFormRecordsets(vData As FormRecordsets)
      mudtFormRecordsets = vData
End Property

Public Property Get udtFormRecordsets() As FormRecordsets
      udtFormRecordsets = mudtFormRecordsets
End Property

should work. Explanation: the value of the property is stored in
Code:
mudtFormRecordsets
and the property let/get procedures just act as an intermediate method to get the value in that private variable. You always need some storage with property procedures.

[idea] Something else: I think it is wise to use a separate class module to store the recordsets (privately) in. The manipulation of the recordsets is than best placed in the same class module. If you design it right, the rest of your program probably need not even know the recordsets exist.

 
Sorry - yes I had already supplied a private var but it still doesn't work.......the problem I get that if in another module I do

set theAboveClass.udtFormRecordsets.rec4dgdMain = recMyRecordset

It just doesn't work....it doesn't fall over but it doesn't work. If I step through the code the call references the 'Get' procedure when really I want to 'Let' or nmore appropriately 'Set' but I get errors if I try 'Setting'
 
It looks to me that the Get property of the mudtFormRecordsets is returning the correct type structure, but you really don't have a corresponding Let property to an individual recordset within the type structure, which is what the set assignment statement is trying to do. The only Let property that is defined is to the overall type structure.

I think that you will need to either 1, define Let/Get properties for each of the individual recordsets within the type structure, or 2), build the type structure within the form code, and then make the overall type structure assignment to the class. It feels like the second option may be more inituitive to implement.


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top