D
DowningDevelopments
Hello everyone,
I am making a database that stores information about student tenants for a
housing company. I am building a from which will help them to see which rooms
are empty and which are taken. The rooms are kept in a table called
[StudentRooms] and the students are kept in a table called [students].
The studentRooms table has a combination key consisting of Building, Block,
Flat and RoomNo which act as foreign keys in the Students table.
I had a query which i thought worked but have now found doesnt, each student
has a [StartDate] and an [EndDate] and i was using the following query to
check to see if a room was available (it basically says, find all the rooms
where the building, block and flat are matching whats on the form and the
startdate of the new student is more than the end date of an existing
student):
SELECT StudentRooms.RoomNo, Students.EndDate, Students.StudentRef
FROM StudentRooms LEFT JOIN Students ON (StudentRooms.BuildingRef =
Students.Building) AND (StudentRooms.BlockRef = Students.BlockNo) AND
(StudentRooms.Flatref = Students.FlatNo) AND (StudentRooms.RoomNo =
Students.RoomNo)
WHERE (((StudentRooms.BuildingRef)=[forms]![StudentsNew]![Building]) AND
((StudentRooms.BlockRef)=[forms]![StudentsNew]![BlockNo]) AND
((StudentRooms.Flatref)=[forms]![StudentsNew]![FlatNo]) AND
((Students.EndDate)<[Forms]![StudentsNew]![Startdate]))
ORDER BY StudentRooms.BuildingRef;
What should i be doing to find out if a room is empty right now?
with thanks
Amit
I am making a database that stores information about student tenants for a
housing company. I am building a from which will help them to see which rooms
are empty and which are taken. The rooms are kept in a table called
[StudentRooms] and the students are kept in a table called [students].
The studentRooms table has a combination key consisting of Building, Block,
Flat and RoomNo which act as foreign keys in the Students table.
I had a query which i thought worked but have now found doesnt, each student
has a [StartDate] and an [EndDate] and i was using the following query to
check to see if a room was available (it basically says, find all the rooms
where the building, block and flat are matching whats on the form and the
startdate of the new student is more than the end date of an existing
student):
SELECT StudentRooms.RoomNo, Students.EndDate, Students.StudentRef
FROM StudentRooms LEFT JOIN Students ON (StudentRooms.BuildingRef =
Students.Building) AND (StudentRooms.BlockRef = Students.BlockNo) AND
(StudentRooms.Flatref = Students.FlatNo) AND (StudentRooms.RoomNo =
Students.RoomNo)
WHERE (((StudentRooms.BuildingRef)=[forms]![StudentsNew]![Building]) AND
((StudentRooms.BlockRef)=[forms]![StudentsNew]![BlockNo]) AND
((StudentRooms.Flatref)=[forms]![StudentsNew]![FlatNo]) AND
((Students.EndDate)<[Forms]![StudentsNew]![Startdate]))
ORDER BY StudentRooms.BuildingRef;
What should i be doing to find out if a room is empty right now?
with thanks
Amit