Hi there peoples,
First ever post on Tek-tips, so after struggling with this for a couple of days and searching the web, I thought I would try this.
How can you use VBA in Excel to open an existing MS Access Query "qryEquityP" (set up to accept user supplied perameters "PDate" [ISO Date field YYYYMMDD ie "20031212"] and "Ticker" [ie "TSCO"])??
This should return just one value in my pre-established query. Normally I use SQL to create a new query, but I just wanted to see if there was an effecient way to call this Query (set up to accept the user-defined parameter through the use of "[]" in the field).
Any coding example would be much appreciated!!
Thanks Matt
First ever post on Tek-tips, so after struggling with this for a couple of days and searching the web, I thought I would try this.
How can you use VBA in Excel to open an existing MS Access Query "qryEquityP" (set up to accept user supplied perameters "PDate" [ISO Date field YYYYMMDD ie "20031212"] and "Ticker" [ie "TSCO"])??
This should return just one value in my pre-established query. Normally I use SQL to create a new query, but I just wanted to see if there was an effecient way to call this Query (set up to accept the user-defined parameter through the use of "[]" in the field).
Code:
Sub GetFilesDAOViaQuery()
Dim db As DAO.Database
Dim qd As DAO.QueryDef 'pre-defined Query
Dim rs As DAO.Recordset
Dim p As DAO.Parameter 'Set up the parameter
p = 20031212
Set db = OpenDatabase("Y:\Portfolio.mdb", False, False)
Set qd = db.QueryDefs("qryEquityP")
end sub
Any coding example would be much appreciated!!
Thanks Matt