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

Creating Class Properties Based on Recordset

Status
Not open for further replies.

bobbarker

Programmer
Dec 20, 2001
83
0
0
GB
Am new to object orientated programming and what to do things right....

I have a recordset and I want to create properties automatically in a class that match the fields in the recordset.

I want to, in some way, bind text box controls on a form to the class properties and then have class methods to update the recordset accordingly.

For example. A recordset called 'Names' that has three fields: 'Forename' (string 10 characters), 'Surname' (string 20 chars), 'Age' (long).

In my class called, say, clsNames I want to create three properties automatically based on the three fields, i.e. without having to code Get and Let statements manually.

I then want three text boxes on a form to be bound to the class properties.

Any suggestions would be appreciated.
 
Dynamically creating the Class properties based on the recordset schema is, in my opinion, an 'ambitious' goal for someone new to (object orientated) programming.

The 'exercise' can, of course be completed, simply reading the db schema (see the oft refered to {F1} (aka H W L P) for terms which are new to you) and generating the bits of code (Let & Get property functions), inserting same into the (Class) module. Some variation in the further 'details' of the exercise suggest that proceeding beyond this (all to brief) outline would not be particularly helpful. 'Binding' controls to the 'fields' of the [class | recordset] is, perhaps, a bit ambigious, as a goal, particularly in the situation of creating the class module. Binding would be accomplished easily through the data control, and thus (also) having the class procedures do it may not be the best strategy.

While there is an occassional discussion (thread) re the merits of bound vs unbound forms and controls, these are more opften found in the Ms. A. Forum. (pure) VB programmers appear to have pretty well decided (on an individual basis) which path to take in this matter. There are 'situations' which might dictate one approach for a specific app (sharing a db / table w/ another app which has control over the access methods and where the db doesn't support different methods 'simultaneously'), but otherwise, the choice seems to be an 'individual' preference.





MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top