D Darren Dec 30, 2004 #1 I need to run a query from code and be able to retrieve values from it. Probably simple, but it's giving me a headache. Thanks
I need to run a query from code and be able to retrieve values from it. Probably simple, but it's giving me a headache. Thanks
R Rick Brandt Dec 30, 2004 #2 Darren said: I need to run a query from code and be able to retrieve values from it. Probably simple, but it's giving me a headache. Thanks Click to expand... You would typically use the query to open a RecordSet object and then you can retrieve the data from that in your code. VBA has no way to pull data from a query directly other than to use DLookup() against it.
Darren said: I need to run a query from code and be able to retrieve values from it. Probably simple, but it's giving me a headache. Thanks Click to expand... You would typically use the query to open a RecordSet object and then you can retrieve the data from that in your code. VBA has no way to pull data from a query directly other than to use DLookup() against it.
D Darren Dec 30, 2004 #3 Actually, I figured it out. Thanks Dim rs As DAO.Recordset Dim db As Database Dim qry As DAO.QueryDef Set db = CurrentDb() Set qry = db.QueryDefs("qryGetLastRegNum") Set rs = qry.OpenRecordset
Actually, I figured it out. Thanks Dim rs As DAO.Recordset Dim db As Database Dim qry As DAO.QueryDef Set db = CurrentDb() Set qry = db.QueryDefs("qryGetLastRegNum") Set rs = qry.OpenRecordset
S Steve Schapel Dec 30, 2004 #4 Darren, That's probably more complicated than you need. This will do the job... Dim rs As DAO.Recordset Set rs = CurrentDb.OpenRecordset("qryGetLastRegNum")
Darren, That's probably more complicated than you need. This will do the job... Dim rs As DAO.Recordset Set rs = CurrentDb.OpenRecordset("qryGetLastRegNum")