Re: DoCmd.RunSQL error Help
From: fredg (fgutkind_at_example.invalid)
Date: 04/29/04
- Next message: Kate: "Re: Help with hiding/showing forms"
- Previous message: Kate: "Help with code to run query and test a field in the record"
- In reply to: Kate: "DoCmd.RunSQL error Help"
- Next in thread: Kate: "Re: DoCmd.RunSQL error Help"
- Reply: Kate: "Re: DoCmd.RunSQL error Help"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 29 Apr 2004 22:16:40 GMT
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.
- Next message: Kate: "Re: Help with hiding/showing forms"
- Previous message: Kate: "Help with code to run query and test a field in the record"
- In reply to: Kate: "DoCmd.RunSQL error Help"
- Next in thread: Kate: "Re: DoCmd.RunSQL error Help"
- Reply: Kate: "Re: DoCmd.RunSQL error Help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|