Re: DoCmd.RunSQL error Help

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


Date: Thu, 29 Apr 2004 16:15:54 -0700

Trouble with that is I then want to test a field (Booking
ID) in the returned record and I get an error message
Object required. Any thoughts

>-----Original Message-----
>On Thu, 29 Apr 2004 13:33:23 -0700, Kate wrote:
>
>> 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));
>
>RunSQL will only run Action queries.
>
>Create a query using your SQL.
>Then Run the query from your code event.
>DoCmd.OpenQuery "QueryName"
>--
>Fred
>Please only reply to this newsgroup.
>I do not reply to personal email.
>.
>



Relevant Pages

  • Re: 2 table Query Error
    ... Post the SQL statement of the query that is giving you this error. ... It is a Country club member accounting database. ... > member ID to member ID) I get the afore memtioned error message. ...
    (microsoft.public.access.queries)
  • Re: Inline CrossTab Query
    ... The SQL I used I just copied from the three queries in the Query Design ... >> I am trying to produce a SQL statement to bring together 3 queries ... >> I am getting an error message that says there is an Error in the ...
    (microsoft.public.access.queries)
  • Re: Query Help
    ... error message, so I know what i want I just don't know how to get there. ... "Jeff Boyce" wrote: ... if I could get you to post back the SQL statement that your query ...
    (microsoft.public.access.queries)
  • Re: Syntax error in INSERT INTO statement.
    ... Still get the same error message in Access. ... This is the query I ran in Access, that I copied from browser. ... > Run the page and look at the sql statement in the browser window. ...
    (microsoft.public.scripting.vbscript)
  • Re: Update query and filter by selection
    ... The error message indicates that there is something in the SQL statement ... e.g. a misspelt field name. ... it runs the query directly from the code, ...
    (microsoft.public.access.queries)