Data Acess via OOP

W

Weste

I am attempting my 1st Access 97 application using OOP. I have an unbound
form. On the form is a button to allow users to search a table based on
TitleID. The query can return multiple records. The primary key in the
table is TrackingID. I have created a Property Let procedure for TitleID.
See code below.

Public Property Let TitleID(Value as Long)
m_TitleID = Value

Dim db as DAO.Database
Dim rs as DAO.Recordset
Dim lngCount as Long

Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT TrackingID FROM tblPositions " _
& "WHERE TitleID = " & m_TitleID & ";", dbOpenSnapshot)

rs.MoveLast
lngCount = rs.RecordCount
rs.MoveFirst
m_Array = rs.GetRows(lngCount)

rs.Close
set rs = Nothing
Set db = Nothing

End Property

The code behind the search button assigns the selected value by the user to
the object's TitleID property. The form's fields are then populated based on
the object's properties. I have navigation buttons on the form which get the
TrackingID from the array and then re-populates the form based on the new
TrackingID.

I'm not sure if this method is the most efficient? The OOP examples I have
seen extracting data from a database only pull a single record. Any comments
or alternative methods would be greatly appreciated. Thanks!

Weste
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top