Solved

HELP I need a little help...

Posted on 2004-04-17
13
318 Views
Last Modified: 2007-12-19
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 :(
0
Comment
Question by:sirbounty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
13 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 10850733
I'd check two things.

1.  Is there a DataSource type declared somewhere?
2.  Is Insurance an object?
0
 
LVL 1

Assisted Solution

by:Ryan9999
Ryan9999 earned 50 total points
ID: 10850745
i would look at mDataService and see if it is either out of scope or spelled wrong
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10851762
>>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...:(
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 76

Accepted Solution

by:
David Lee earned 200 total points
ID: 10851835
1.  If DataSource is a user defined type, then it must be declared somewhere.  You should be able to find something like:

Type DataSource
End Type

2.  Based on the line of code "Set Insurance = mDataService", yes, Insurance is an object.  But it's possible that the object declaration is missing and that's causing the problem.

My guess is that DataSource is defined as a type.  Consider this code fragment.

Private Sub Command1_Click()
    Dim varTest As Testing
End Sub

If you create a new project, drop this code into it, be sure to add a command button called Command1, and step through it you should get the same error you're reporting.  Since the only data type I see in the code you indicate as generating the error is DataSource, I have to suspect that it isn't defined (i.e. there is no type declaration).  A simple test to see if that's the case would be to create a type declaration for it and see if the error goes away.  If it does, then that's the problem.  Solving it is more of a problem unless you can discover what the proper type declaration is supposed to be.  If that doesn't make the error go away, then my guess is wrong.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10851857
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.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 10851902
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.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10851925
...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.. :(
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10851988
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?
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10851993
Doh! I removed ADO 2.6 and added 2.7 and I get as far as Form_Load finally... :D
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10851997
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
0
 
LVL 76

Expert Comment

by:David Lee
ID: 10853681
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.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10899733
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...
0
 
LVL 67

Author Comment

by:sirbounty
ID: 10929070
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..
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question