Variable value from query

  • Thread starter Thread starter Neal Ostrander
  • Start date Start date
N

Neal Ostrander

I have a query that takes the sum of one comlum and subtracts the sum of
another column to get the balance. Is there a way to run this query in vba
and assign the returned value to a variable.

Thanks
Neal
 
I have a query that takes the sum of one comlum and subtracts the sum of
another column to get the balance. Is there a way to run this query in vba
and assign the returned value to a variable.

Thanks
Neal

dim curReturnValue as currency
dim qdf as dao.querydef
dim rs as dao.recordset
set qdf=Dbengine(0)(0).Querydefs("QueryName")
set rs=qdf.openrecordset

curReturnValue=rs.fields("Total")

you mean something like that?
 
Is the coding the same using ADO?


dim curReturnValue as currency
dim qdf as dao.querydef
dim rs as dao.recordset
set qdf=Dbengine(0)(0).Querydefs("QueryName")
set rs=qdf.openrecordset

curReturnValue=rs.fields("Total")

you mean something like that?
 
Is the coding the same using ADO?

not exactly the same, but similar.
use an ADO command and an ADO recordset, and you can do the same thing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top