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