Variable value from query

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
 
P

pietlinden

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?
 
N

Neal Ostrander

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?
 

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

Top