Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass Through With Parameters, how to read recordset

Status
Not open for further replies.

mwolf00

Programmer
Nov 5, 2001
4,177
US
This function works
Code:
Function rwaInfo(MyParam As String)

         Dim MyDb As Database, MyQry As QueryDef, MyRS  As DAO.Recordset
         Set MyDb = CurrentDb()
         Set MyQry = MyDb.CreateQueryDef("")

         MyQry.Connect = "ODBC;DSN=abc;DBQ=def;UID=xxxxx;PWD=xxxxx"

         MyQry.SQL = "SELECT * FROM VAT WHERE RWA_NO = '" & MyParam & "'"

         MyQry.ReturnsRecords = True
         Set MyRS = MyQry.OpenRecordset()
         MyRS.MoveFirst

        'Debug.Print MyRS!rwa_no

         MyQry.Close
         MyRS.Close
         MyDb.Close

End Function

now I want to query the function from Access SQL and return all of the data in the recordset. Can this be done?

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
zen.gif
 
Why not using a linked table instead ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The linked table returns the "too many indexes" error...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
zen.gif
 
I would create the pass-through query as a query object, with it's own unique name. Then, query that query.

If you need to reference the RWA_NO for the query, just reference a field in a form you have open or recreate the query definition in code before running it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top