Game_Addicted
Nov 9 2004, 03:56 PM
How can I do a select of data using Access SQL, I try this and receive an error
strSQLSelectData = strSQLSelectData & "SELECT ([TD1]) AS TestData "
strSQLSelectData = strSQLSelectData & "FROM tblTemp;"
CurrentDb.Execute strSQLSelectData
Cannot execute a select query. (Error 3065)
I realize that I am doing it incorrectly, but I dont have enough SQL knowledge.
I need to select some data and then use that data to query for other data.
Any Ideas would be helpful
ScottGem
Nov 9 2004, 04:00 PM
Try this:
strSQLSelectData = "SELECT [TD1] AS TestData "
strSQLSelectData = strSQLSelectData & "FROM tblTemp;"
CurrentDb.Execute strSQLSelectData
HTH
Game_Addicted
Nov 9 2004, 04:15 PM
Get the same error
Run Time Error (Error 3065)
Cannot execute a select query.
ScottGem
Nov 9 2004, 04:19 PM
Let's see the whole code module
Game_Addicted
Nov 9 2004, 04:47 PM
Not much to it just started triing to get they info.
Sub aVarIndCalcAfterTrendsFound()
Dim strSQLSelectData As String
Set TempSet = dbase.OpenRecordset("tblTemp", dbopendynaset)
'xxxxxxxxxxxx Determine Trend Pick from tblTemp then do calcs xxxxxxxxxxx
'strSQLSelectData = strSQLSelectData & "SELECT Max([TD1]) AS TestData "
'strSQLSelectData = strSQLSelectData & "FROM tblTemp;"
'CurrentDb.Execute strSQLSelectData
strSQLSelectData = "SELECT [TD1] AS TestData "
strSQLSelectData = strSQLSelectData & "FROM tblTemp;"
CurrentDb.Execute strSQLSelectData
End Sub
ChrisO
Nov 9 2004, 09:36 PM
G’day Game_Addicted.
A select query can not be executed because it might return something and there is no place for that something to go.
BTW. There is also a possible error in that there may be no space between TestData and FROM.
Difficult to see because of my poor old eyes.
Regards,
Chris.
ScottGem
Nov 9 2004, 09:55 PM
Whoops I should have picked up on the Select query. What is it you are trying to accomplish?
Chaga
Nov 10 2004, 01:14 AM
From Access Help.
The Execute method is valid only for action queries. If you use Execute with another type of query, an error occurs. Because an action query doesn't return any records, Execute doesn't return a Recordset. (Executing an SQL pass-through query in an ODBCDirect workspace will not return an error if a Recordset isn't returned.)
For Select queries, use a recordset.
Game_Addicted
Nov 10 2004, 10:09 AM
The peice of code was just the beginning of what I'm tryiing to do
Here is what I'm actually trying to do
I have a table with mutliple records and 3 feilds, the field contain numbers only.
I am trying to go thru the first field and pick the highest number, there could be several records with the same number being the highest.
Once the high number is selected look at just those records and then pick the highest number out of the second field.
Once the high number is selected look at just those records and then pick the highest number out of the third field.
Any advice for a complete rookie would be helpful
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.