getting a recordset from a class

G

Guest

I have a number of subforms that relate to a single master form. I would like
to call a class that acts as a "dataservice" to get the record set for each
of the differnt pices of information. The problem is that I am not sure how
to make the module recordset equal the recordset from the class.

strSeed = Forms("station").Controls("txtstationid")

Set objrs = New Recordset
Set objrs = mDataService.GetRecordset(strSeed, "earthmat")

Where the mDataservice is the reference to my class and "earthmat" is the
name of the table.

The function in the class looks like this:

Function GetRecordset(strSeed As String, strTableName As String) As Recordset
Dim objrs As Recordset
Dim strQuery As String

strQuery = "Select * from " & strTableName & " where stationid = '"
& strSeed & "'"

objrs.Open strQuery, CurrentProject.Connection, adOpenDynamic,
adLockBatchOptimistic

GetRecordset = objrs
Return
objrs.Close
objrs = Nothing

End Function


Perhaps I am going beyond the abilities of Access 2000

Thanks in advance
 
G

Guest

If I understand what you are trying to accomplish, you are not going beyond
the abilities of Access, you are going around them.
If you mean by "pieces of information", the recordsets for the various sub
forms are going to be unique.
The recordset for a form (or sub form, no difference) is usually specified
in design view. It is possible to specify it a run time, but that is an
unusual case. All you really need to do if you want the recordsets in the
sub forms to sync with the current record in the master form is to set the
Link Master Fields and Link Child Fields properties of the subform control on
your main form. Then when you set the source object property of the sub form
control, also set the Link Master Fields and Link Child Fields property.
 

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