G
Guest
Hello all
I’ve been running into a problem when trying to modify the SQL statements contained in my query. I want to be able to change the number of records returned by my SELECT… FROM statement. To do this, I have written the following code and call it into action by way of a command button on a form
Sub CreateSQL(
DoCmd.OpenQuery “SQL String Queryâ€, acViewNormal, acEdi
Dim strSQL As Strin
strSQL = "SELECT TOP 75 tblExam.Question, tblExam.[Choice A], tblExam.[Choice B], tblExam.[Choice C], tblExam.ID, tblExam.[Choice D], tblExam.[Choice E]" &
" FROM tblExam " &
" ORDER BY Rnd([ID]);
DoCmd.RunSQL strSQ
End Su
I debug the code without any problems, but when I click the command button in the form I get the following error
Run-Time Error 2342: A RunSQL action requires an argument consisting of an SQL statement
This same statement works if I type in manually into the Query’s SQL View, so I’m not sure what I’m doing wrong. Many thanks in advance
I’ve been running into a problem when trying to modify the SQL statements contained in my query. I want to be able to change the number of records returned by my SELECT… FROM statement. To do this, I have written the following code and call it into action by way of a command button on a form
Sub CreateSQL(
DoCmd.OpenQuery “SQL String Queryâ€, acViewNormal, acEdi
Dim strSQL As Strin
strSQL = "SELECT TOP 75 tblExam.Question, tblExam.[Choice A], tblExam.[Choice B], tblExam.[Choice C], tblExam.ID, tblExam.[Choice D], tblExam.[Choice E]" &
" FROM tblExam " &
" ORDER BY Rnd([ID]);
DoCmd.RunSQL strSQ
End Su
I debug the code without any problems, but when I click the command button in the form I get the following error
Run-Time Error 2342: A RunSQL action requires an argument consisting of an SQL statement
This same statement works if I type in manually into the Query’s SQL View, so I’m not sure what I’m doing wrong. Many thanks in advance