Solved

Problem with Datasource Class

Posted on 2000-04-09
8
308 Views
Last Modified: 2013-12-25
I have a textbox whose datasource is an ADO Data Connector.  When I chance the recordset Property on the ADODC and call refresh, the contents of the textbox change to reflect the new recordset.

When I bind a textbox to a class that is a datasource, and change the contents of the class recordset, I am not able to get the contents of the textbox to change.  The first time the datasource is set for the textbox, the GetDataMember method of the class is called, but subsequent changes to the datasource don't generate calls to the GetDataMember Event.  For example, the sequence
         set t.datasource = Nothing
         Set t.Datasource = X
where x is a member of the datasource class, doesn't generate a GetDataMember event.

Can anyone help me with this one?

thanks
0
Comment
Question by:garyz31
[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
  • 4
  • 4
8 Comments
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2703719
Okay, maybe there's something not quite correct with the way you deal with the event

Create an Event in your datasourceclass:

Public Event DataChanged

'Now the rest of your class's methods and properties

After you change the recordset in any way -> fire the event:

RaiseEvent DataChanged

Make sure you Declare the variable t like this:

Dim WithEvents t as YourDataClass

If you're sure you've done all this, then I'd like to take a look at your dataclass's code to see what might go wrong.

See ya...
0
 
LVL 1

Author Comment

by:garyz31
ID: 2704720
OK, I'll give that a try later today.
0
 
LVL 1

Author Comment

by:garyz31
ID: 2705263
I'm planning to try your suggestions later today, but I wanted to check something with you first.  Are there advantages to binding a control to a datasource class object, rather than exposing a recordset as a property, linking that recordset to an ADODataConnector object, and binding the control to the ADODataConnector?

Thanks
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2711392
Oops, I've not been able to check my mail for a couple of days, so I'm sorry for my late reaction.

Well there are some advantages to it as well as disadvantages. Of course having the recordset as a property and hand it over (ByRef) is easy coding. On the other hand, I use dataclasses because I want to check for validity of the data entered, want some fields to be updated based on user-entries in another one, etc... in one single class and not at every form where I use it. I personally think it's cleaner that way and furthermore it's easier to maintain your code.
0
 
LVL 1

Author Comment

by:garyz31
ID: 2712303
I appreciate that it is very useful to have the recordset, withevents in a class that takes care of all the tasks of maintaining the recordset.  However, does it actually matter by which method the recordset is bound to a control; by making the class a datasource, or exposing the recordset as a read-only property and binding it through controls through an ADO Data Connector?

Thanks
0
 
LVL 2

Accepted Solution

by:
p_biggelaar earned 75 total points
ID: 2715229
Well, using an ADODC means extra overhead, so less performance. Furthermore in this approach controls would be directly bound to the recordset so changes are applied directly to the recordset. In some cases this might be okay, while sometimes you want to be able to validate the input, or perform other actions based on specific input. If that's what you want, go for the first approach.

I'm not sure whether this is good enough for you or not. If not: let me know..
0
 
LVL 1

Author Comment

by:garyz31
ID: 2718304
I finally got the binding to work, and I thank you for that.  I'm still not convinced about the event processing advantages of the datasource class approach.  My understanding that as long as a recordset is a member of a class, it can be declared "WithEvents", whether or not the class is a datasource.  I'll be experimenting more to see if this approach makes my application operate more efficiently.

thanks
0
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2718752
Your welcome..
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month4 days, 17 hours left to enroll

635 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