View Full Version : Subform/Combo Box Woes


Tracer
12-20-2001, 12:17 AM
I am trying to set up a database of patient information. My main form is the patient demographics. My subform is a list of their current doctors (datasheet view). I have created the doctor subform using two separate tables, and linking them to the main form with Patient ID. (Child and Master are linked using Patient ID). I have managed to get the subform to work using a combo box so I can choose using surnames, from a list of 2600 doctors and once I choose the doctor their address etc. shows up. The record in this subform also shows patient ID correctly. My problem is that as soon as I go to the next patient record and then return to look at the doctor's that I just entered in my subform, they are no longer there. i.e. I enter the doctors in the subform, but they will not stay attached to the individual patient record. Hope this makes sense. It is driving me crazy. I am using Access 2K.
HELP!

SteveA
12-21-2001, 02:12 PM
When you place a subform on a main form you have to set two values on the subform field. These are Link Child Fields and Link Master Fields. If you set Link Child Fields to PatientID and Link Master Fields to which ever field in the Patient table has their unique number (probably Patient ID), the subform will automatically assign the new record in the subform to the patient displayed in the main form.

HTH
SteveA http://www.access-programmers.co.uk/ubb/smile.gif

Tracer
12-21-2001, 02:23 PM
I have already done that Steve? Any other suggestions?

SteveA
12-21-2001, 06:38 PM
If you look at the database tables, are the records being saved correctly?

Cheers,
SteveA

Pat Hartman
12-21-2001, 06:45 PM
Is the subform in Add mode? Have you looked at the underlying tables to determine if the records you added are there?

Tracer
12-22-2001, 12:50 PM
Hi Steve and Pat. Thanks for our reply. Pat, I am not sure what 'add' mode is?? With regards to the tables. I checked and it appears that the diagnosis' subform information is saving in the query table, just not showing in the form view (I enter it and go to another record , and come back and it is not showing). the doctor subform on the other hand, does not appear to be saving in a table anywhere. Could this have something to do with the fact that the doctor subform was created using two separate tables (Dr. table and ref Dr. table), instead of creating the subform using a query of the necessary info from thoses two tables? i.e. diagnosis subform saving in a table, but once entered, not showing in form view. Doctor subform on the other hand doesn't seem to be saving in a table, and once entered, not showing in the form view either? I have double checked the master and child links, and they are all linked with Patient ID. Hope this makes sense. Thanks.

Tracy

Pat Hartman
12-22-2001, 01:43 PM
Look at the Data tab of the diagnosis Form's properties dialog. If the DataEntry property is set to yes, the form will only allow additions. It will not show existing records. That would explain why once you leave the parent record you can never see the subform detail again. The Doctor form could also be set to DataEntry = yes.

I ALWAYS make my own queries so that I can test them and store them as querydefs so I have never selected multiple tables when using the form wizard. I believe that the form wizard simply makes its own query and stores it in the form's recordset so the form should still be bound but you could check. I would replace the recordsource for this form with a query of my own making.

Jack Cowley
12-22-2001, 01:45 PM
I think Pat means in 'Add mode' that you have the Allow Additions property set to Yes so you can add new records. If you are adding new records and they are being saved to the table then you should be OK.

The form based on two tables has to be based on a query that is based on the two tables. And the reason you may not be seeing the data after you enter it is because the form needs to be 'requeried' so it 'sees' the latest addition(s). Search Help for Requery as well as Refresh to find out how to refresh your forms.

Tracer
12-22-2001, 08:11 PM
Thanks so much for the suggestions. I will give them a try and get back to you. http://www.access-programmers.co.uk/ubb/smile.gif

Tracy