@mloucel You are very far into this database so you probably don't want to hear this but here goes anyway.
You programed in COBOL for a long time so you are not afraid of writing code. What this has done is prevent you from actually understanding Access which is a RAD (Rapid Application Development) tool which does a lot of stuff for you if only you would let it. That means you start with bound forms. You use querydefs rather than embedded SQL. You use property settings. You use VBA functions. And when you can't get it done with a query or a VBA function or a property setting, then and ONLY then do you write code. You don't start with unbound forms and try to code all the necessary behavior yourself.
You need to gradually, one at a time, convert ALL your unbound forms to be bound and learn to take advantage of Form and Control level events to place any necessary non-generic code. Think of all the hidden code behind a form that was written by the Microsoft people and which you cannot ever see as the "mainline". In that mainline, the form's code recognizes events (things that the user does or that happen as part of navigation through a recordset bound to a form. These events become "hooks" which are exposed to you so that you can add custom code when one of these events happens. Remember writing COBOL? You create an outline of what the program will do with "stubs" which do nothing except return to the mainline. These "stubs" translate to Events in Access, either Control level or Form level. You always need code but not for the stuff you are using it for. You need code to do the things that are not generic and so Access cannot do for you. So, you always need validation code and your validation code determines whether or not records get saved to the tables. When a form is bound you can open it using the OpenForm Method and pass in an ID. If the ID is found, the record is displayed which is exactly what you want and you need NO CODE to populate the form's data fields. If the ID is not found, the form opens ready to add a new patient. It works sooooooo smoothly and logically, it is almost magical. But you really need to let Access be Access or you will never be at ease with creating applications using it.
Your current methods are causing you to build multiple forms for every table to handle add/view/edit separately. All you ever need is ONE form. Occasionally, your validation code will need to distinguish between add/update but most of it will be the same.
I can probably count on one hand the number of times I have made the decision to have two forms update the same record. In those cases, the validation code was in a separate module and called from the BeforeUpdate event of each form so that if something changed, I only needed to modify ONE procedure. An example of this might be if a child record has too many fields to display nicely in a one line list. In that case, I display all required fields and he most important other fields so the user doesn't have to open a second form if he wants to change something. But the subform has a double click event that will open a single record data edit form that shows ALL fields should the user need to get to those less important fields to view or update them.
Hello
@mike60smart ,
@theDBguy ,
@MajP and of course
@Pat Hartman
I'll try to answer all of you here.
Maybe this will explain a bit better the issue..
This is the Table where the info is SAVED the first time, once I have found the Patient:
This is how I do it:
I need first to find the patient so I use this form, based on a query, to find the patient, I am only interested in the record ID, but since I need to display the name, DOB and phone, [in the Form I have the issue].
This is the SEARCH form and Query:
This Form Passes the PatientID to AddAuthorizationsF [as mentioned by you
@Pat Hartman ]
I need to move this data to the ADDAuthorizationF, [
Displayed in #1] remember I ONLY need the ID saved to the above Table, see second FIELD [PatientID] so the Name, DOB and Phone are for DISPLAY purposes only.
ALL other fields in #1 are INITIALIZED, so the EU will pick whatever the Authorization needs, so that FORM IS BOUND to the AuthorizationsT, but this table, only saves ID's, from the rest of the other tables:
Now, that's when the problem comes:
The EU or mostly the patient may have different Authorizations, GI, Optometry and Dietitian, or more.
FOR NOW, once I finish one authorization the EU goes out to the main menu, and starts the whole process again:
- Main Menu
- Search for the Patient
- once found Add a new authorization
Go Back to Main Menu..
That is why I need to ADD that feature to the AddNewAuthorizationF so that the EU doesn't have to go back over and over again.
So as you can see the LastName / FirstName / DOB and Phone are sort of transferred just display only not important [when I pick a Patient, only the ID is transferred to the bound form, as you can see, I am following (I THINK) the rules you set me (and I appreciate), since ALL other fields are going to start ALWAYS from DEFAULT values; except for the PatientID, that will be always the same, and once I get to a new record in that form,
I need to display ONLY the LN, FN, DOB and Phone again, but all other fields start from defaults.
Every time I try to start the form for a new record, I lose everything.
I hope this is better explanation.
just need to create a new record but keep the PatientID
and somehow, get the FN, LN, DOB and Phone from the PatientT display them and start a new Authorization for that patient, as many times as he/she has authorizations.
Sorry for the long explanation but as you can see, the form is bound as it should be.
Any help will be appreciated.
Maurice.