Aug 08 2023 11:54 PM
I have a database for animals in a zoo. Animal ID information (and lifelong data which won't change) is in an ID table. (Tbl_PC_Animal_ID)
During its life each animal may have one or more health issues which are recorded in another table (Tbl_Issues) with a 1 to many relationship to the 1st table on ID-Key.
In response to each health issue the animal may receive one or more drugs over varying periods
Drug treatments are recorded in third level table (TblRx) linked by the Issue ID key from Issues table.
Treatment records have a start and end date which may be days or months apart. I am avoiding having a record for every animal for every drug for every day, but I do want a way for staff to acknowledge, and check if an animal has been treated on each particular day, (in a separate very simple table called TblCheckOffCompletedMeds, with just 4 fields, home key, RxKey, Date and completed yes/no)
I have a query (Below) which has animal ID, drug name , start date, end date etc to draw animal ID and drug treatment data together, having [Date to check off] in the criteria for this Query makes Access prompt to type in a date. That date is held in expression1as a binary. I can't make this other than a binary. (or if I can please let me know how)
SELECT Tbl_PC_Animal_ID.Species, Tbl_PC_Animal_ID.[House name], Tbl_PC_Animal_ID.[Microchip~tag~physicalID], Tbl_Rx.Drug, Tbl_Rx.Frequency, Tbl_Rx.Rx_Key, [Date to check off] AS Expr1
FROM (Tbl_PC_Animal_ID LEFT JOIN TblVetIssues ON Tbl_PC_Animal_ID.ID_Key = TblVetIssues.Animal_Key) LEFT JOIN Tbl_Rx ON TblVetIssues.Issue_Key = Tbl_Rx.Issue_Key
WHERE (((Tbl_Rx.[Finish date])>=[Date to check off]) AND ((Tbl_Rx.[Start date])<=[Date to check off])) OR (((Tbl_Rx.[Finish date]) Is Null) AND ((Tbl_Rx.[Start date])<=[Date to check off]));
This query populates a form which shows only animals on treatment on the date entered as [Date to check off]. No data is entered by the master form but it allows inputter to see which animal drug combination is to be checked off in the subform.
The subform is enters records to TblCheckOffCompletedMeds.
My problem is that I can’t get linked master/child fields to work due to one being a date field and one being a binary field.
This leads to records from other days showing up in the subform.
Can anyone help with this or suggest the much simpler way that I have probably overlooked.
Cheers
Vere Nicolson
Aug 09 2023 05:52 AM - edited Aug 09 2023 05:54 AM
If I read this correctly, I think you have a design problem. "I am avoiding having a record for every animal for every drug for every day,"
That cripples the concept of a "database" by deliberately omitting critical information. Did any given animal actually receive the medication or medications that animal should get on any given day? You have no way to verify that and that means NONE of the data is reliable. The way you seem to be doing it doesn't actually save any significant amount of data entry either, does it? You have to check off the days on which "some animals" were given "some medications" by "some employee", so there's still significant data entry.
I believe the problem with the query could be resolved by some appropriate modifications to the SQL, but in the absence of reliable data, it hardly seems worthwhile.
You need a properly designed table in which your users record the date, the ID of the animal, the ID of the employee who administered the medication, the ID of each medication that animal received, and the dosage that animal received of each medication. You can manage an interface to minimize the effort required to do so, but without it, your data is virtually useless because it assumes "if something was scheduled to happen, someone must have done it, right?"
Aug 09 2023 11:56 AM
Aug 09 2023 04:00 PM
Aug 10 2023 06:56 AM