Access 2003
Hi All,
I am running the code below, and get an error:
It is giving me run time error 2342 " A RUNSQL action requires an argument of consisting of an SQL statement." Then in debug it highlights "DoCmd.RunSQL sqlmv" in yellow.
The query runs fine in design view (it checks for duplicates on a combination of two fields), but in VBA it does not.
Could anyone shed some light as to why it wont run in VBA?
Many thanks.
Michael
Hi All,
I am running the code below, and get an error:
Code:
Private Sub Command2_Click()
Dim sqlmv As String
sqlmv = "SELECT First(SVT_ALL.MVRIS_MAKE_CODE) AS [MVRIS_MAKE_CODE Field], First(SVT_ALL.MVRIS_MODEL_CODE) AS [MVRIS_MODEL_CODE Field], Count(SVT_ALL.MVRIS_MAKE_CODE) AS NumberOfDups FROM SVT_ALL GROUP BY SVT_ALL.MVRIS_MAKE_CODE, SVT_ALL.MVRIS_MODEL_CODE HAVING (((Count(SVT_ALL.MVRIS_MAKE_CODE))>1) AND ((Count(SVT_ALL.MVRIS_MODEL_CODE))>1));"
DoCmd.RunSQL sqlmv
End Sub
It is giving me run time error 2342 " A RUNSQL action requires an argument of consisting of an SQL statement." Then in debug it highlights "DoCmd.RunSQL sqlmv" in yellow.
The query runs fine in design view (it checks for duplicates on a combination of two fields), but in VBA it does not.
Could anyone shed some light as to why it wont run in VBA?
Many thanks.
Michael