DoCmd.RunSQL Error 
Author Message
 DoCmd.RunSQL Error

When attempting to run the following code (event from a
combobox) I get the following error:
"A RunSQL action requires an argument consisting of an SQL
statement." Run-time error 2342

Private Sub cboDeptStrategy_AfterUpdate()

On Error GoTo EH

'after the user selects a dept. strategy in the dropdown
box
'this code will run to collect all the other information
related
'to the dept. strategy. Currently will not recognize the
sql statement.

Dim stSQL As String 'variable for sql statement

'sql statement to select everything from the table with
the dept. strategy.
stSQL = "Select * From dbo_tblDeptStrategy;"

'run the sql statement
DoCmd.RunSQL stSQL

Exit_eh:
    Exit Sub

EH:
    MsgBox Err.Description & Err.Number
    Resume Exit_eh

End Sub

any help would be greatly appreciated.
Thanks, JR



Mon, 05 Dec 2005 05:55:39 GMT  
 DoCmd.RunSQL Error
The DoCmd.RunSQL command does not work for non-action queries. You're trying
to use it to run a "select" query, which is a non-action query. ("Action"
queries are "append", "delete", "make-table", etc. type of queries.)

What are you wanting to do with the results of the query? That info is
needed in order to give you some suggestions.

--
       Ken Snell
<MS ACCESS MVP>


Quote:
> When attempting to run the following code (event from a
> combobox) I get the following error:
> "A RunSQL action requires an argument consisting of an SQL
> statement." Run-time error 2342

> Private Sub cboDeptStrategy_AfterUpdate()

> On Error GoTo EH

> 'after the user selects a dept. strategy in the dropdown
> box
> 'this code will run to collect all the other information
> related
> 'to the dept. strategy. Currently will not recognize the
> sql statement.

> Dim stSQL As String 'variable for sql statement

> 'sql statement to select everything from the table with
> the dept. strategy.
> stSQL = "Select * From dbo_tblDeptStrategy;"

> 'run the sql statement
> DoCmd.RunSQL stSQL

> Exit_eh:
>     Exit Sub

> EH:
>     MsgBox Err.Description & Err.Number
>     Resume Exit_eh

> End Sub

> any help would be greatly appreciated.
> Thanks, JR



Mon, 05 Dec 2005 06:21:24 GMT  
 DoCmd.RunSQL Error
My plan is to store the information in variables, display
the information in text boxes for the users review then
later (in the same screen) write the information to the
proper table.

Thanks for the information regarding the difference in a
action vs. non-action query. I think I may have an idea
but any suggestion you have would be greatly appreciated.

Thanks, JR

Quote:
>-----Original Message-----
>The DoCmd.RunSQL command does not work for non-action

queries. You're trying
Quote:
>to use it to run a "select" query, which is a non-action
query. ("Action"
>queries are "append", "delete", "make-table", etc. type
of queries.)

>What are you wanting to do with the results of the query?
That info is
>needed in order to give you some suggestions.

>--
>       Ken Snell
><MS ACCESS MVP>



>> When attempting to run the following code (event from a
>> combobox) I get the following error:
>> "A RunSQL action requires an argument consisting of an
SQL
>> statement." Run-time error 2342

>> Private Sub cboDeptStrategy_AfterUpdate()

>> On Error GoTo EH

>> 'after the user selects a dept. strategy in the dropdown
>> box
>> 'this code will run to collect all the other information
>> related
>> 'to the dept. strategy. Currently will not recognize the
>> sql statement.

>> Dim stSQL As String 'variable for sql statement

>> 'sql statement to select everything from the table with
>> the dept. strategy.
>> stSQL = "Select * From dbo_tblDeptStrategy;"

>> 'run the sql statement
>> DoCmd.RunSQL stSQL

>> Exit_eh:
>>     Exit Sub

>> EH:
>>     MsgBox Err.Description & Err.Number
>>     Resume Exit_eh

>> End Sub

>> any help would be greatly appreciated.
>> Thanks, JR

>.



Mon, 05 Dec 2005 23:04:32 GMT  
 DoCmd.RunSQL Error
If you want to display the results of the query in textboxes, why not use a
subform in the form, and set the recordsource of the subform to the SQL
statement that you're building (and then requery the subform's
recordsource)?

--
       Ken Snell
<MS ACCESS MVP>


Quote:
> My plan is to store the information in variables, display
> the information in text boxes for the users review then
> later (in the same screen) write the information to the
> proper table.

> Thanks for the information regarding the difference in a
> action vs. non-action query. I think I may have an idea
> but any suggestion you have would be greatly appreciated.

> Thanks, JR
> >-----Original Message-----
> >The DoCmd.RunSQL command does not work for non-action
> queries. You're trying
> >to use it to run a "select" query, which is a non-action
> query. ("Action"
> >queries are "append", "delete", "make-table", etc. type
> of queries.)

> >What are you wanting to do with the results of the query?
> That info is
> >needed in order to give you some suggestions.

> >--
> >       Ken Snell
> ><MS ACCESS MVP>



> >> When attempting to run the following code (event from a
> >> combobox) I get the following error:
> >> "A RunSQL action requires an argument consisting of an
> SQL
> >> statement." Run-time error 2342

> >> Private Sub cboDeptStrategy_AfterUpdate()

> >> On Error GoTo EH

> >> 'after the user selects a dept. strategy in the dropdown
> >> box
> >> 'this code will run to collect all the other information
> >> related
> >> 'to the dept. strategy. Currently will not recognize the
> >> sql statement.

> >> Dim stSQL As String 'variable for sql statement

> >> 'sql statement to select everything from the table with
> >> the dept. strategy.
> >> stSQL = "Select * From dbo_tblDeptStrategy;"

> >> 'run the sql statement
> >> DoCmd.RunSQL stSQL

> >> Exit_eh:
> >>     Exit Sub

> >> EH:
> >>     MsgBox Err.Description & Err.Number
> >>     Resume Exit_eh

> >> End Sub

> >> any help would be greatly appreciated.
> >> Thanks, JR

> >.



Tue, 06 Dec 2005 08:57:39 GMT  
 DoCmd.RunSQL Error
That's a good idea! I will give it a try. Thank you for
the help you've provided, it is very much appreciated.
JR
Quote:
>-----Original Message-----
>If you want to display the results of the query in

textboxes, why not use a
Quote:
>subform in the form, and set the recordsource of the
subform to the SQL
>statement that you're building (and then requery the
subform's
>recordsource)?

>--
>       Ken Snell
><MS ACCESS MVP>



>> My plan is to store the information in variables,
display
>> the information in text boxes for the users review then
>> later (in the same screen) write the information to the
>> proper table.

>> Thanks for the information regarding the difference in a
>> action vs. non-action query. I think I may have an idea
>> but any suggestion you have would be greatly
appreciated.

>> Thanks, JR
>> >-----Original Message-----
>> >The DoCmd.RunSQL command does not work for non-action
>> queries. You're trying
>> >to use it to run a "select" query, which is a non-
action
>> query. ("Action"
>> >queries are "append", "delete", "make-table", etc. type
>> of queries.)

>> >What are you wanting to do with the results of the
query?
>> That info is
>> >needed in order to give you some suggestions.

>> >--
>> >       Ken Snell
>> ><MS ACCESS MVP>



>> >> When attempting to run the following code (event
from a
>> >> combobox) I get the following error:
>> >> "A RunSQL action requires an argument consisting of
an
>> SQL
>> >> statement." Run-time error 2342

>> >> Private Sub cboDeptStrategy_AfterUpdate()

>> >> On Error GoTo EH

>> >> 'after the user selects a dept. strategy in the
dropdown
>> >> box
>> >> 'this code will run to collect all the other
information
>> >> related
>> >> 'to the dept. strategy. Currently will not recognize
the
>> >> sql statement.

>> >> Dim stSQL As String 'variable for sql statement

>> >> 'sql statement to select everything from the table
with
>> >> the dept. strategy.
>> >> stSQL = "Select * From dbo_tblDeptStrategy;"

>> >> 'run the sql statement
>> >> DoCmd.RunSQL stSQL

>> >> Exit_eh:
>> >>     Exit Sub

>> >> EH:
>> >>     MsgBox Err.Description & Err.Number
>> >>     Resume Exit_eh

>> >> End Sub

>> >> any help would be greatly appreciated.
>> >> Thanks, JR

>> >.

>.



Tue, 06 Dec 2005 23:29:06 GMT  
 DoCmd.RunSQL Error
You're welcome. Good luck!


Quote:
> That's a good idea! I will give it a try. Thank you for
> the help you've provided, it is very much appreciated.
> JR
> >-----Original Message-----
> >If you want to display the results of the query in
> textboxes, why not use a
> >subform in the form, and set the recordsource of the
> subform to the SQL
> >statement that you're building (and then requery the
> subform's
> >recordsource)?

> >--
> >       Ken Snell
> ><MS ACCESS MVP>



> >> My plan is to store the information in variables,
> display
> >> the information in text boxes for the users review then
> >> later (in the same screen) write the information to the
> >> proper table.

> >> Thanks for the information regarding the difference in a
> >> action vs. non-action query. I think I may have an idea
> >> but any suggestion you have would be greatly
> appreciated.

> >> Thanks, JR
> >> >-----Original Message-----
> >> >The DoCmd.RunSQL command does not work for non-action
> >> queries. You're trying
> >> >to use it to run a "select" query, which is a non-
> action
> >> query. ("Action"
> >> >queries are "append", "delete", "make-table", etc. type
> >> of queries.)

> >> >What are you wanting to do with the results of the
> query?
> >> That info is
> >> >needed in order to give you some suggestions.

> >> >--
> >> >       Ken Snell
> >> ><MS ACCESS MVP>



> >> >> When attempting to run the following code (event
> from a
> >> >> combobox) I get the following error:
> >> >> "A RunSQL action requires an argument consisting of
> an
> >> SQL
> >> >> statement." Run-time error 2342

> >> >> Private Sub cboDeptStrategy_AfterUpdate()

> >> >> On Error GoTo EH

> >> >> 'after the user selects a dept. strategy in the
> dropdown
> >> >> box
> >> >> 'this code will run to collect all the other
> information
> >> >> related
> >> >> 'to the dept. strategy. Currently will not recognize
> the
> >> >> sql statement.

> >> >> Dim stSQL As String 'variable for sql statement

> >> >> 'sql statement to select everything from the table
> with
> >> >> the dept. strategy.
> >> >> stSQL = "Select * From dbo_tblDeptStrategy;"

> >> >> 'run the sql statement
> >> >> DoCmd.RunSQL stSQL

> >> >> Exit_eh:
> >> >>     Exit Sub

> >> >> EH:
> >> >>     MsgBox Err.Description & Err.Number
> >> >>     Resume Exit_eh

> >> >> End Sub

> >> >> any help would be greatly appreciated.
> >> >> Thanks, JR

> >> >.

> >.



Wed, 07 Dec 2005 09:06:30 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. DoCmd.RunSQL error 2

2. error 2342 with docmd.runsql

3. DoCmd.RunSQL

4. docmd.RunSql problem

5. docmd.RunSQL String Concatenation

6. DoCmd.RunSQL too long record

7. DoCmd.RunSQL

8. suppress warnings on DoCmd.RunSQL ?

9. docmd.runsql repeat problem

10. docmd.runsql help required

11. DoCmd.RunSQL vs. Recordsets

12. docmd.runSQL fails on Windows 2000

 

 
Powered by phpBB® Forum Software