Action query behaves differently with DoCmd than with Execute

SunWuKung

Registered User.
Local time
Today, 04:59
Joined
Jun 21, 2001
Messages
172
I met the following strange situation:
I have a MakeTable Query, it runs smoothly with DoCmd.RunSQL SQLstring but when I want to do the same thing with dbs.Execute SQLstring it gives a too few parameters expected 1 error. How is this possible? Do I have something wrong in the syntax (can't be in the SQLstring othervise it wouldn't work with DoCmd), or is it something else?

Thanks for the help.

SWK


----------- Here is the code I use --------------------------------

Private Sub CreateExportFile_Click()
Dim dbs As DAO.Database
Dim SQLstring As String

Set dbs = CurrentDb
SQLstring = "SELECT [SelectCandidate].[C_TITLE], [SelectCandidate].[C_SNAME], [SelectCandidate].[C_FNAME], [SelectCandidate].[C_SEX], [SelectCandidate].[S_SCALETAG], Min([SelectNorm].[Value]) AS StenScore INTO ExportedCands" & _
" FROM SelectCandidate INNER JOIN SelectNorm ON ([SelectCandidate].[INTEGER_VALUE]<=[SelectNorm].[Minimum]) AND ([SelectCandidate].[S_SCALETAG]=[SelectNorm].[Scale])" & _
" GROUP BY [SelectCandidate].[C_TITLE], [SelectCandidate].[C_SNAME], [SelectCandidate].[C_FNAME], [SelectCandidate].[C_SEX], [SelectCandidate].[S_SCALETAG]" & _
" ORDER BY [SelectCandidate].[C_SNAME], [SelectCandidate].[S_SCALETAG];"

DoCmd.RunSQL SQLstring 'works

...but...

dbs.Execute SQLstring 'yield an error
 
Not sure if it's the answer but I use this
Dim CurDB As DATABASE, SQLStmt As String
Set CurDB = DBEngine.Workspaces(0).Databases(0)
CurDB.Execute SQLStmt
 
Thanks for the try Rich, but I am getting the same error message with your method too.

Any other thoughts? I can't find the explanation.

Thanks.
SWK
 

Users who are viewing this thread

Back
Top Bottom