I'm going around and around in circles of ever increasing frustration
I have a form, on my form I have a combobox which contains the IDs of all the patients in my database. The form is for editing existing records and adding new records every time a patient fills in a form. It is possible for the patient to exist in the database, but have no form entries. It is also possible that the patient may not be in the database at all.
I would like to use the combobox purely for searching records, not for overwriting existing data. The process I am going for is
- If the patient does not exist in the database ask user (via a dialog box) if they would like to add them. If yes, open the form for adding new patients. Set ID value in main form back to a value that exists.
- If a patient exists but does yet have any records associated to them inform the user (via dialog box) and ask them if them would like to add a first record for this patient. If yes, go to new record and auto-fill ID box with the user entered ID. Otherwise, revert back to ID (and record) shown before user updated value.
- If patient exists and has records, use a filter to find them all.
My current problem is with item 2. I can go to a new record and auto-fill the ID number. I enable all the other controls on the form so that the user can set their values for this record. However, I can't seem to be able to save this new record correctly though. When the user updates the value in the ID box again, to search and filter for the next patient, the new record is saved with this ID and not the ID intended.
The ID combo box should never allow existing data to be overwritten.
Can anyone help me with this please?