Solved

Access function returning a recordset

Posted on 2012-03-15
3
485 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…

810 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