Query into Report textbox

J

JMG

Help!

There are two things I would like to do First, I would like VBA to run the
following query:

InsQry1 = "SELECT surquestion.hhhead, surquestion.floor FROM surquestion
GROUP BY surquestion.hhhead, surquestion.floor;"

however, if I use the DoCmd.RunSQL I get a runtime error "2342". So how Do I
get the VBA to run the query

Second, I would like to output the results into two textboxs of a report (eg
Reports!Report1.Text1 and Reports!Report1.Text2). How do I reference the
query output? As I am rather a newbie please list all declarations.

Thanks
JMG
 
D

Duane Hookom

There are several methods of getting the results of a query into a report.
Since you are selecting two fields, I would suggest a subreport based on the
query. If you only need one field from one record, you could use DLookup().
 
D

Duane Hookom

I should have also stated that DoCmd.RunSQL is for action queries, not
select queries.
 

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