View attachment 115652
I may have to find time to re-construct the entire database.
Do you think the single table format is the reason why DMax doesn't work on certain date-of-birth matches?
Just as a general rule, if you attempt to use ACCESS or ANY software product in a manner in which it was never designed to be used, you will have nothing but problems. In your case, using DMax (or any other built-in functions) may work, or they may not. DMax can certainly work if you construct the criteria properly. Of course, if you have multiple patients in multiple hospitals with the same DOB, your results could be, well, unreliable.
As other have pointed out, when you are working with dates in ACCESS, it can be very confusing when you are building the criteria part of the function. It would be much, much easier to just design the thing properly from the beginning and you wouldn't need to DMax the latest date for each patient and view it in a text box. All you would need to do is go to that last record in a form. No need to DMax anything.
If you want help in normalizing your data into a relational model, here's what you can do:
- Copy the database and re-name the new copied file Hospital_Testing.accdb
- Open Hospital_Testing.accdb
- Create new fields called PatientNum and ConsultantNum and give each patient and consultant a number so they are all anonymous to outsiders. You can use the Number Data Type or Short Text.
- Keep the HospitalNumber field but clear all the hospital names in the Hospital field, so we have numbers but not names.
- Keep all the other fields as they are. They mean nothing to any outsiders.
- Attach the Hospital_Testing.accdb file by posting a new reply and attaching the file using the Attach files button.
If you don't wish to use outside help, looking at what you have now, after normalization and creating proper relationships, there could be, for example:
- A Hospital table with multiple hospitals. Each hospital has a Hospital Name, Number and Consultant assignment.
- A Patients table. Each hospital will have multiple patients. Each patient has a SurName, FirstName and DOB (and any other information you wish to keep).
- A TestData table. Each patient will have multiple testing data records including a TestDate field and test criteria fields such as NK69 information and Beads information and test result information.
- The Hospital table is connected with the Patient table with a HospitalID foreign key field
- The Patient table is connected with the TestData table with a PatientID foreign key field
Once the tables are designed, then import ONLY Hospital information into the hospital table, ONLY patient information into the patient table and ONLY Testing data into the TestData table.
Only after the tables and fields are designed do you make forms, queries and reports.