Access function returning a recordset

Hi
Using Microsoft Access 2010.  The code below failed on the line as indicated with the message "Invalid use of property"..... "rs" is the target of the error message.


How do I properly call the function below?

Thanks

private sub test()
      Dim rs As DAO.Recordset
      rs = GetRecordSet(Me.[Stock #])       '-------------  Fails here.  
end sub



Public Function GetRecordSet(ByRef TheKey As Long) As DAO.Recordset
Dim strTable As String: Dim StrSQL_Select_Str As String
Dim str1 As String: Dim Str2 As String

strTable = "[Table -- List of Stock Items]"
str1 = "SELECT * FROM " & strTable
Str2 = " Where [Stock #] = " & [Stock #]
StrSQL_Select_Str = str1 & Str2
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(StrSQL_Select_Str, dbOpenDynaset)  ' Get record in [Table -- Retail  / Consigners SKU and Prices]
GetRecordSet = rs
End Function
peispudAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
what do you need the recordset for ?

change this

      rs = GetRecordSet(Me.[Stock #])      

with

      set rs = GetRecordSet(Me.[Stock #])
0
 
peispudAuthor Commented:
I am using the recordset to get a record from another table.  If it's there,  then I will be updating a field or two in that table.
0
 
peispudAuthor Commented:
Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.