Link to home
Start Free TrialLog in
Avatar of sirbounty
sirbountyFlag for United States of America

asked on

HELP I need a little help...

Man...I'm trying to learn class modules and multitier database applications...
So I just finished typing in like 30 pages of code (the sample project from my training manual).
I was going to step through it so I could watch the whole boring process....
Well, it errors out immediately on one of my modules with this error:

User-defined type not defined.

This is within my CPatient module on a property:

Public Property Get Insurance() As DataSource
    'Expose the data source to bind to the DataCombo box
    Set Insurance = mDataService
End Property

Can someone tell me where to begin to look for the answer?  It's got to be a type-o on my part since I copied it out of the book...(I hope :(
Avatar of David Lee
David Lee
Flag of United States of America image

I'd check two things.

1.  Is there a DataSource type declared somewhere?
2.  Is Insurance an object?
SOLUTION
Avatar of Ryan9999
Ryan9999

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sirbounty

ASKER

>>1.  Is there a DataSource type declared somewhere?<<
What would I be looking for?

>>2.  Is Insurance an object?<<
Doesn't the property above indicate that it is?  (that's sounds a bit sarcastic, but it's not, I assure you)

>>i would look at mDataService and see if it is either out of scope or spelled wrong<<
I searched for all instances of mData and all came up with Service spelled correctly.

I did find a couple of instances of CDataService, mistyped as CDataSource - but that didn't change anything...:(
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nope - there's no Type DataSource anywhere...

Here's the head of the CPatient module...

'=========================
Option Explicit

'Create an instance of the Data Services Class
Private mDataService As CDataService

'Declare a BindingCollection to bind data source and data consumer
Private mbndPatient As BindingCollection

'Declare properties for Patient (Note alphabetic order)
Private mstrCity As String
Private mstrFirstName As String
Private mstrInsuranceCompanyCode As String
Private mstrLastName As String
Private mintPatientNumber As Integer
Private mstrPhone As String
Private mstrPolicyNumber As String
Private mstrState As String
Private mstrStreet As String
Private mstrZipCode As String

'Enum for error code
Public Enum paError
    paValidationError = vbObjectError + 512 + 100
End Enum

'******Property Procedures*******

Public Property Get Insurance() As DataSource
    'Expose the data source to bind to the DataCombo box
    Set Insurance = mDataService
End Property
'============================


I added

Private Type DataSource
End Type

but get an error on that ..."User defined type without members not allowed"

I can't imagine this not being in the code though if it is needed.  I copied this strait from the text.  I could imagine a type-o, but not missing a section like this.
Could be that the text is just wrong, I suppose (sure is a lot of wasted time for me typing it all in though >:(

I've bumped the points some... I'd really like to get this working so I can begin to have a better understanding here.

Thanx for all your help so far.
Yes, the Type declaration needs at least one member.  Sorry, I just used Type, End Type as an example.  Try adding this and see if that clears the problem up.

Private Type DataSource
   varData as Variant
End Type


I agree that it seems unlikely that a required Type declaration would be missing from the sample program text.  But I've seen things like that happen.  I'm probably wrong and it's something else, but the error message points in this direction so I'm just trying to be methodic and eliminate it as a possibility.
...and I DO appreciate you're helping me here.

Okay - with that addition, I'm now getting the following:

Compile Error:
Private Enum and user defined types cannot be used as parameters or return types for public procedures, public data members, or fields of public user-defined types.

And it's flagging my Insurance property again.. :(
Hmm - one other thing before the code in the manual.
Add references to your project for MS Data Binding Collection, which I did and the MS Active X Data Object 6.0 Library.
Mine only goes as high as 2.7, so I assumed this was a type-o referencing 2.6?
Doh! I removed ADO 2.6 and added 2.7 and I get as far as Form_Load finally... :D
Private Sub Form_Load()
    'Set up the form controls to handle data
    Set mPatient = New CPatient
   
    With dbcInsurance       'Bind DataCombo to data source
        .DataMember = "Patient"
        Set .DataSource = mPatient.Insurance
        .rowMember = "Insurance"                       '<-----------This is where it stops though.  Method or data member not found
        Set .RowSource = mPatient.Insurance
        .ListField = "Name"
    End With
   
    mnuSortPatientNumber_Click  'Set initial sort order & display data
    DisplayRecordCount
End Sub
That's progress.

The online help in VB6 describes the .RowMember property like this:

The RowMember property is equivalent to the DataMember property, and is used to fully qualify which set of data to bind to. When a data source supplies more than one data member, you must specify which to use before setting the DataField property.

I don't know what is meant by "equivalent to the DataMamber property".  It could mean that the value RowMember is set to must be the same value DataMember is set to.  Whatever it means though it seems clear that the program isn't finding a RowMember named Insurance.  You could try setting RowMember to Patient, the same value used in DataMember.  I'd also propose looking at the data source to see if it contains anything called Insurance.  The best way I can think of to do that is to open the data source and look at its properties.
Sorry for the delay - on the form, I have a dbCombo, dbcInsurance.
It's properties do not list a rowmember, only a rowsource - so I'm wondering if I chose the wrong control....
Ever hear of ADO 6.0?  That one still confuses me...
Oh well, I think I've given up...
I'll move on to the next chapter and hopefully get something from it there.
Thanx for the help though..