Use function to return recordset?

N

Network Telephone

I am trying to create a public function that returns a recordset in Access
2003. Is this possible?
 
W

WC Justice

In order to provide more information, I add the following:

I may use the following in a number of modules:

strSQL = "SELECT * FROM tblContracts WHERE ContractNumber = " &
dblContractNumber

set rs = currentdb.OpenRecordset(strSQL)

I would like to move that to a public function to be called, i.e.

set rsContractData =ContractData(dblContractNumber)

This is a simplistic example, but I just need to know if it is possible.
Thanks
 
D

Douglas J. Steele

I can't guarantee it'll work (since I'm too lazy to test <g>), but try:

Function ContractData(ContractNumber As Double) As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT * FROM tblContracts " & _
"WHERE ContractNumber = " & ContractNumber

Set ContractData = CurrentDb.OpenRecordset(strSQL)

Exit Function
 
Top