Dear developers,
I am developing an equipment database where some of my coworkers can add projects and assign the necessary equipment to the project. One of the main features of such a system is of course to see if a piece of equipment is available for a project. I have made an application involving three databases: a project database, an equipment database and a transactions database (a column linked to the ID of the project database and a column linked to the equipment database). When a project is added or changed, the user will have the option to click a button in order to assign equipment to the project via a form. In this form I would like to have a query which only shows the available equipment at the time of the project. Meaning that if a piece of equipment does not have transactions between the start date and the end date of the period, the piece of equipment is available to use.
I wrote a query which handles this, however, I have one problem with this query and after searching almost the complete internet, I still haven't found a solution. The problem is that if the query runs it checks for transactions between the start and end date of the project, if there are no transactions, the piece of equipment is shown as available, as expected. If there is only one transaction for that particular piece of equipment and it is between the start and the end date of the project the piece of equipment is not shown, also as expected.
However if the piece of equipment has multiple transactions where one is between the start and the end date of the project and there is at least one (historic) transaction not between the start and the end date of the project, the piece of equipment is still shown as available for the project. My question is if anyone knows a solution for this, meaning that if a piece of equipment is ignored once because at least one transaction is between the start and end date of a project, the particular piece of equipment is ignored completely and is not shown available.
I have searched a lot and tried a lot and you guys are basically my last hope for this function. I hope you are able to give me some tips or workarounds to solve this.
Thanks in advance for your time and effort,
Kind Regards,
Jordy