Process records from a query

B

Brian C

I have an Availability table that look like this:

Booking Date
Period
Room
Booking Id

I have a form to query availability and I can run the
following SQL to get a record:

SELECT AVAILABILITY.BookingDate, AVAILABILITY.Period,
AVAILABILITY.Room, 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]));

I want to change this SQL to get all Rooms for that period
so I believe I need to code an * so do I change the last
part to be:
((AVAILABILITY.Room)="*"));

This will return multiple records so how do I then process
each record in turn to check the Booking ID field?

I want to check it for value 1 and if any record returned
contains 1 put a message on my form to say select another
room. If none contains 1 then I want to put a message on
my form to say select another date or period.
 
T

Treebeard

Brian C said:
I have an Availability table that look like this:

Booking Date
Period
Room
Booking Id

I have a form to query availability and I can run the
following SQL to get a record:

SELECT AVAILABILITY.BookingDate, AVAILABILITY.Period,
AVAILABILITY.Room, 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]));

I want to change this SQL to get all Rooms for that period
so I believe I need to code an * so do I change the last
part to be:
((AVAILABILITY.Room)="*"));

If Availability isn't an issue, why don't you just remove it from the query?

SELECT AVAILABILITY.BookingDate, AVAILABILITY.Period,
AVAILABILITY.Room, AVAILABILITY.[Booking ID]
FROM AVAILABILITY
WHERE (((AVAILABILITY.BookingDate)=forms![SINGLE BOOKING
AVAILABILITY]![BookingDate]) AND ((AVAILABILITY.Period)
=forms![SINGLE BOOKING AVAILABILITY]![Combo8])) ;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

syntax error? Help 2
Put message to form 1
Help me ! 4
DoCmd.RunSQL error Help 5
Process multiple records 1
Getting data from forms 2
Update not working 1
Syntax error 1

Top