peispud
asked on
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(St rSQL_Selec t_Str, dbOpenDynaset) ' Get record in [Table -- Retail / Consigners SKU and Prices]
GetRecordSet = rs
End Function
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(St
GetRecordSet = rs
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
ASKER