Access 2010 Runtime Error 2342
Contents |
Social Groups Pictures & Albums Members List Calendar Search Forums Show Threads Show Posts Tag Search Advanced Search Find All Thanked Posts Go to Page...
Runtime Error 7874
Thread Tools Rating: Display Modes 02-24-2008, 05:51 PM #1 vba run select query doco Power User Join Date: Feb 2007 Location: E.Oregon, USA Posts: 467 Thanks: 19 Thanked 4 Times a runsql action requires an argument consisting of an sql statement in 3 Posts ERROR 2342 DoCmd.RunSQL Quote: Example The following example updates the Employees table, changing each sales manager's title to Regional Sales Manager: Public Sub DoSQL() Dim SQL As String
Select Query In Access Vba
SQL = "UPDATE Employees " & _ "SET Employees.Title = 'Regional Sales Manager' " & _ "WHERE Employees.Title = 'Sales Manager'" DoCmd.RunSQL SQL End Sub Yet no manner of SQL statement is accepted without error. The following example is an oversimplification to make a point. Code: DoCmd.RunSQL "Select * from dbo_property" ' or even populating a variable SQL = "Select * from
Openrecordset Access
dbo_property" DoCmd.RunSQL SQL ' throws same error Throws Run Time error '2342' : "A RunSQL action requires an argument consisting of an SQL statement" Even copy and paste SQL directly from Access QBE SQL editor of a query that does indeed work without error, throws the same error. Any ideas? TIA __________________ Consensus is the lack of leadership doco View Public Profile Visit doco's homepage! Find More Posts by doco 02-24-2008, 07:01 PM #2 ajetrumpet Banned Join Date: Jun 2007 Location: Universe - Local Group - Milky Way Galaxy - Orion Arm Posts: 5,640 Thanks: 0 Thanked 94 Times in 43 Posts Quote: Originally Posted by doco Any ideas? Yes, you are violating a very simple rule in Visual Basic: Action commands in Visual Basic can only carry out actions. This includes queries, or SQL statements that represent queries. The reason you are getting the error is probably because the SQL statement you are dealing with does not constitute an action. Action queries are: UPDATE, DELETE, APPEND, and MAKE TABLE. These are the only ones that can be u
Guest Guest of an SQL statement" Hello, I cannot figure out what is wrong with the code below. I keep getting the above runtime error. But it select statement in vba runs no problem in Desiqn Query mode, once I've set the primary keys
Ms Access Openrecordset
for the two tables. Any idea what the problem is? Dim strSQL As String strSQL = "SELECT zmax2.*, rooting2.* " docmd.runsql select & _ "FROM zmax2 LEFT JOIN rooting2 " & _ "ON zmax2.musym = rooting2.musym" 'Turn off warning message. DoCmd.SetWarnings False DoCmd.RunSQL strSQL 'Re-enable warning message DoCmd.SetWarnings True RichardA Guest, Jun 14, 2004 http://www.access-programmers.co.uk/forums/showthread.php?t=144266 #1 Advertisements John Spencer (MVP) Guest RunSql requires an action query - DELETE, APPEND, UPDATE, ... A SELECT query is NOT an action query. What are you trying to accomplish with this code? Open a recordset? Display a query? RichardA wrote: > > of an SQL statement" > > Hello, I cannot figure out what is wrong with the code below. I keep getting the above runtime http://www.pcreview.co.uk/threads/runtime-error-2342-a-runsql-action-requires-an-argument-consist.1639011/ error. But it runs no problem in Desiqn Query mode, once I've set the primary keys for the two tables. Any idea what the problem is? > > Dim strSQL As String > strSQL = "SELECT zmax2.*, rooting2.* " & _ > "FROM zmax2 LEFT JOIN rooting2 " & _ > "ON zmax2.musym = rooting2.musym" > > 'Turn off warning message. > DoCmd.SetWarnings False > > DoCmd.RunSQL strSQL > > 'Re-enable warning message > DoCmd.SetWarnings True > > RichardA John Spencer (MVP), Jun 15, 2004 #2 Advertisements Van T. Dinh Guest RunSQL can only be used to run an *Action* Query (Append / Update / Delete), and NOT a Select Query. -- HTH Van T. Dinh MVP (Access) "RichardA" <> wrote in message news:... > of an SQL statement" > > Hello, I cannot figure out what is wrong with the code below. I keep getting the above runtime error. But it runs no problem in Desiqn Query mode, once I've set the primary keys for the two tables. Any idea what the problem is? > > Dim strSQL As String > strSQL = "SELECT zmax2.*, rooting2.* " & _ > "FROM zmax2 LEFT JOIN rooting
Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for https://www.experts-exchange.com/questions/23377056/DoCmd-runSQL-and-run-time-error-'2342'-A-RunSQL-action-requires-an-argument-consisting-of-an-SQL-statement.html Help Receive Real-Time Help Create a Freelance Project Hire for https://bytes.com/topic/access/answers/872780-runsql-command-acces-vb-return-run-time-error-2342-a a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > DoCmd.runSQL and run-time error '2342' A RunSQL action requires runtime error an argument consisting of an SQL statement. Want to Advertise Here? Solved DoCmd.runSQL and run-time error '2342' A RunSQL action requires an argument consisting of an SQL statement. Posted on 2008-05-05 Query Syntax 1 Verified Solution 9 Comments 2,081 Views Last Modified: 2010-04-21 HI I am banging my head trying to update a access 2010 runtime numeric field on a subform "parts" for an assembly X. The se parts must be numbered in order from 1 to X without stepping over a number - even if some parts get deleted or inserted. Here is how I ave tried to do it... Can you help me and tell me what I am doing wrong ? Thanks Private Sub Form_BeforeUpdate(Cancel As Integer) Dim RS As dao.Recordset Dim strSQL As String strSQL = "SELECT Design_Struct.*, Design_Struct.[DesiID] " & _ "FROM Design_Struct " & _ "WHERE Design_Struct.[DesiID]= '" & Me.DesiID.Value & "';" DoCmd.RunSQL strSQL If D_StrNo Is Null Then D_StrNo = 1 End Else Do Until RS.EOF D_StrNo = (D_StrNo + 1) RS.MoveNext Loop End End If End Sub Select all Open in new window 0 Question by:SirTKC Fa
Ask a Question Need help? Post your question and get tips & solutions from a community of 418,417 IT Pros & Developers. It's quick & easy. runsql command in acces VB return "Run time error 2342" P: 2 stpgmn I'm executing the following procedure within Access mdb. The query that I'm trying to run works nolrmally when executed as Query. Do anybody has any idea of reason of the error?. Thanks a lot Private Sub Form_BeforeInsert(Cancel As Integer) Dim Istruz As Variant Dim MaxOfVersione As Integer Istruz = "SELECT Max(ControlloVersioniBDG.Versione) AS MaxOfVersione" _ & " FROM ControlloVersioniBDG" _ & " GROUP BY ControlloVersioniBDG.BDGType, ControlloVersioniBDG.Anno" _ & " HAVING (ControlloVersioniBDG.BDGType=[Forms]![F_BDG]![TipoBDG])" _ & " AND (ControlloVersioniBDG.Anno=[Forms]![F_BDG]![DetControlloVersioni])" DoCmd.RunSQL Istruz [Forms]![NewControlloVersioniBDG]![Versione].DefaultValue = MaxOfVersione + 1 End Sub Aug 13 '09 #1 Post Reply Share this Question 5 Replies Expert 100+ P: 1,287 ChipR You Dim MaxOfVersione, but you never set it equal to anything. The "AS MaxOfVersione" in your query just creates a column with that title, and you don't do anything with it. You might want to save the query and then use the DMax() function, or the DLookup() function. Aug 13 '09 #2 reply Expert Mod 2.5K+ P: 2,543 Stewart Ross Hi. Queries referring to form textboxes in their WHERE or HAVING clauses can cause run-time errors when run within the VBA environment. In particular, you may receive a 'too few parameters - expected 1' or somesuch error, which I think is what error 2342 is. To resolve this, pass the value of the form control in the SQL statement, not the name of the control. If your form control holds a string value you need to pass its value inside single quotes, as shown in the HAVING clauses below: Expand|Select|Wrap|Line Numbers &"HAVING(ControlloVersioniBDG.BDGType="_ &"'"&[For