?
Solved

Access function returning a recordset

Posted on 2012-03-15
3
Medium Priority
?
490 Views
Last Modified: 2012-03-15
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
0
Comment
Question by:peispud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 37724830
what do you need the recordset for ?

change this

      rs = GetRecordSet(Me.[Stock #])      

with

      set rs = GetRecordSet(Me.[Stock #])
0
 

Author Comment

by:peispud
ID: 37724886
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
 

Author Closing Comment

by:peispud
ID: 37725778
Thank you
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question