DoCmd.RunSQL error Help

From: Kate (anonymous_at_discussions.microsoft.com)
Date: 04/29/04


Date: Thu, 29 Apr 2004 15:19:04 -0700

Ok. So how do I run an SQL query in my code and have the
results available? Thanks.

>-----Original Message-----
>RunSQL only works with action queries (insert, update
>delete etc) that do not return recordset objects. A
select
>query needs a recordset object to store its results
>>-----Original Message-----
>>I'm trying to execute an SQL statement in a macro
>attached
>>to a form but get error A RunSQL action requires an
>>argument consisting of an SQL statement. What is wrong?
>>
>>Dim strSQL As String
>>
>>strSQL = "SELECT AVAILABILITY.BookingDate,
>>AVAILABILITY.Period, AVAILABILITY.Room," _
>> & "AVAILABILITY.[Day Number], AVAILABILITY.[Booking
>ID] "
>>_
>> & "FROM AVAILABILITY " _
>> & "WHERE (((AVAILABILITY.BookingDate)=Forms![SINGLE
>>BOOKING AVAILABILITY]" _
>> & "!BookingDate) & ((AVAILABILITY.Period)=Forms![SINGLE
>>BOOKING AVAILABILITY]" _
>> & "!Combo8) & ((AVAILABILITY.Room)=Forms![SINGLE
BOOKING
>>AVAILABILITY]!Combo10))"
>>
>>DoCmd.RunSQL strSQL
>>
>>SQL should look like this:
>>
>>SELECT AVAILABILITY.BookingDate, AVAILABILITY.Period,
>>AVAILABILITY.Room, AVAILABILITY.[Day Number],
>AVAILABILITY.
>>[Booking ID]
>>FROM AVAILABILITY
>>WHERE (((AVAILABILITY.BookingDate)=Forms![SINGLE BOOKING
>>AVAILABILITY]!BookingDate) And ((AVAILABILITY.Period)
>>=Forms![SINGLE BOOKING AVAILABILITY]!Combo8) And
>>((AVAILABILITY.Room)=Forms![SINGLE BOOKING AVAILABILITY]!
>>Combo10));
>>
>>.
>>
>.
>



Relevant Pages

  • Re: DoCmd.RunSQL not working
    ... DoCmd.RunSQL is used to run action queries, ... Use DoCmd.OpenQuey instead for your query. ... I am receiving, " A RunSQL ... > action requires an argument consisting of an SQL statement". ...
    (microsoft.public.access.queries)
  • Re: Cant find whats wrong with this SQL
    ... RunSQL applies to action queries. ... SQL string to a QueryDef and OpenQuery if you want to show the results ...
    (microsoft.public.access.queries)
  • Assigning the value of select SQL statements to variables
    ... Is it possible to assign the value of select sql ... I see the "runSQL" method is ... available for action queries, but I dont see how to assing ...
    (microsoft.public.access.formscoding)
  • Re: Equivalent of Get Next Extended to retrieve only unique keys?
    ... The only real "extra" stuff is pertaining to SQL query optimization. ... Bill Bach wrote: ... Retaining the ability to filter on multiple>> items would probably ...
    (comp.databases.btrieve)
  • Re: Setting a Default Value
    ... the make the Sql call from within Application_Start in Global.asax. ... the query string value each time I needed to ... going to assign the default value through a database query. ... run the following SQL query: select * from table where x = 1 ...
    (microsoft.public.dotnet.framework.aspnet)