Filter in Lookup-Settings

Hi, I’m trying to create a Check-box field with a dynamic Lookup-Setting.
The SQL-Term works with static values but I’d like to use dynamic data from the record I am just working on.
How can I link to that on the SQL-Term?
The data in { } is the data I’d like to refer to from the current data inserted into the form.

SELECT room_index,
FROM
kob_room_cal RIGHT OUTER JOIN kob_room ON kob_room_cal.room_nr = kob_room.room_index
WHERE
project_nr = {project_nr}
OR
(kob_room_cal.room_nr IS NULL
)
OR
(begin> {begin} or end < {end})
FROM kob_room

The idea is that only rooms of the project itself or that are in no other project or that are not in the time-frame of another project should be listed to tick.

Can anybody help me there?

Best
Peter