Command button Add new record in Subform

elisanapo

New member
Local time
Yesterday, 19:27
Joined
Nov 1, 2013
Messages
8
Hi,

Please bear with me, I have limited experience with Access!!

I am designing a database to manage hospital patient data. I will have to enter info at various points, e.g. when a patient is referred, admitted, discharged...
So for example, I have a main form with the patient´s name and two subforms, one with the referral details (e.g. date, name of referrer...), and one with the admission details (e.g. date, diagnosis). They are linked through Parent-child links to the main form by PatientID. So, when I enter a new PatientID in the main form, the ID in the subforms is automatically added/synchronized.

However, I would like it not to be...since not all patients that are referred are then admitted. Therefore I would like to have a command button in the main Form that allows me to control when a new patient record is added to the admission subform. In other words, I would like an "Add a new Record in the admissions subform" button, which then creates a new record, with matching PatientID in the admissions subform (and in the related table). Is this possible??? :banghead:

I have tried using the command button wizard but it either requires a record to be already present in the subform, or it takes me to the first record of the form, and not the matching PatientID one.

Any advice would be greatly appreciated! Thanks!
 
Access will not automatically add a new record to a SubForm when a new record is created on the MainForm. It does give you the ability to create a new synchronized record in the SubForm but it is not saved unless you change something in one of the fields in the SubForm.
 
Thanks for your reply.

I think that the problem is that I am using the PatientID as foreign key in the admissions table, so when I enter it in the main form, it is added automatically through the parent-child link and it is considered as a change in a field...
 
Access is *not* doing that. True it will make sure the Foreign Key field contains the LinkMasterFields value but it does it the same way a Default Value works. It does not dirty the record by itself but will insert the value if the user dirties the record in some other fashion.
 
All you should see when you add a new record to the MainForm is one record with probably <new> in it somewhere. Is this the case?
 
Oh yes you've just made my day! I thought it was adding a new record but it wasn't! That's great, thanks!
 
Hi, I have a related question... Is it possible to have a command button in the main form that takes you to a form or subform matched to the current record by Patient ID? I have managed to add an "Open form" command button and I can edit the macro to make it go to the first, last, new, etc records...but I don't manage to match it to the current record of the main form...
I would like to add it so that, instead of having many subforms in the main form, I could just have buttons to link to other forms to enter new info for that record... Is this possible?
Thanks
 

Users who are viewing this thread

Back
Top Bottom