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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help finding undefined variable error

Status
Not open for further replies.

ribbons

Technical User
Apr 26, 2007
113
0
0
US
I'm cleaning up some old code that's been handled by several people, so the question I'm about to ask is probably some minor mistake that I'm just overlooking. But, I've been working on this for some time now, and just can't seem to find the error, so I apologize in advance for trivial-ness.

Here's the code I'm running. This is to initial a class and open a form to adding items to a lookup table.

Code:
Option Explicit
Dim mvarCounty As String
Dim mvarCity As String
Dim mvarDealer As String

Dim WithEvents adoPrimaryRS As Recordset
Private DoingRequery As Boolean
Public Event MoveComplete()

Public Property Let Dealer(ByVal vData As String)
     mvarDealer = vData
End Property
Public Property Get Dealer() As String
   Dealer = mvarDealer
End Property
Public Property Let City(ByVal vData As String)
     mvarCity = vData
End Property
Public Property Get City() As String
   City = mvarCity
End Property

Public Property Let County(ByVal vData As String)
     mvarCounty = vData
End Property
Public Property Get County() As String
   County = mvarCounty
End Property

Private Sub Class_Initialize()
  Dim db As Connection
  Set db = New Connection
  db.CursorLocation = adUseClient
  db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPath

  Set adoPrimaryRS = New Recordset
  adoPrimaryRS.Open "SELECT DealerName, DealerCity, DealerCounty " _
                    & "FROM tb_Dealer_Info " _
                    & "ORDER BY DealerName ASC", db, adOpenStatic, adLockOptimistic
    
    
  DataMembers.Add "Primary"
End Sub

Private Sub Class_GetDataMember(DataMember As String, Data As Object)
  Select Case DataMember
  Case "Primary"
    Set Data = adoPrimaryRS
  End Select
End Sub

When I click on the button to open this form, the program throws a compile error on the
Code:
DataMembers.Add "Primary"

It says the DataMembers variable has not been defined. I've looked all over this code and just can't see the error. New eyes on this would be much appreciated.

ribbons
 
What is DataMembers?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
It is my understanding that "DataMembers" are all the objects that contain data, such as textboxes, etc.

ribbons
 
Ah right, see what you mean now, bit slow there [blush]

Do you have your classes DataSourceBehavior property set to 1 - vbDataSource?

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Hi HarleyQuinn,

I got it. I have no idea exactly what I did, but I just deleted the old stuff and had vb 6.0 add a new form with a class to the project. The code looks exactly the same as what I had before, but it works now. Strange. Thanks for your help anyway.

ribbons
 
Is the new classes DataSourceBehavior property set to 1 - vbDataSource?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top