simple SELECT question

  • Thread starter robertfuschetto via AccessMonster.com
  • Start date
R

robertfuschetto via AccessMonster.com

I have code to delete the contents of a table. I have code to repopulate it.
This works fine.

I tried adding code to group the table contents and open it and the code
fails with an error.

Dim db As Database
Set db = CurrentDb()
sqlstr = "SELECT tbl_TempList.Name1, tbl_TempList.Table1FROM tbl_TempList
GROUP BY tbl_TempList.Name1, tbl_TempList.Table1;"

DoCmd.RunSQL sqlstr

Error results:
A runSQL action requires an argument consisting of an SQL statement.

Ideas?????
 
A

Allen Browne

Try OpenQuery if you want to see the results, or OpenRecordset if you want
to operate on it programmatically without viewing the query output.
 
F

fredg

I have code to delete the contents of a table. I have code to repopulate it.
This works fine.

I tried adding code to group the table contents and open it and the code
fails with an error.

Dim db As Database
Set db = CurrentDb()
sqlstr = "SELECT tbl_TempList.Name1, tbl_TempList.Table1FROM tbl_TempList
GROUP BY tbl_TempList.Name1, tbl_TempList.Table1;"

DoCmd.RunSQL sqlstr

Error results:
A runSQL action requires an argument consisting of an SQL statement.

Ideas?????


You're attempting to run a Select query using RunSQL. You cannot run a
Select query using RunSQL, only action queries, i.e. Delete, Update,
etc. Read VBA help files.
 
R

robertfuschetto via AccessMonster.com

....been trying to get them to install the help files so I can...for now I
must look for a book...do you reccomend one?
I have code to delete the contents of a table. I have code to repopulate it.
This works fine.
[quoted text clipped - 13 lines]
Ideas?????

You're attempting to run a Select query using RunSQL. You cannot run a
Select query using RunSQL, only action queries, i.e. Delete, Update,
etc. Read VBA help files.
 

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

Similar Threads

Almost Have It! One Part of Code incorrect though---Help! 2
help modify code 1
query programming noobie question 1
SQL -- VBA 3
VBA query trouble 4
Using Date fields in SQL 2
SQL - VBA once again 10
recordset? 2

Top