Solved

Access function returning a recordset

Posted on 2012-03-15
3
478 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
  • 2
3 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
what do you need the recordset for ?

change this

      rs = GetRecordSet(Me.[Stock #])      

with

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

Author Comment

by:peispud
Comment Utility
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
Comment Utility
Thank you
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now