I'm trying to mail merge a single record in MS Word. That works. The problem is that single record or row in Access can't be created via SQL alone. I can see how to use vba to get from where I'm at to where I'm going, but I don't want to use vba.
It seems to me that since combo boxes are so normal, writing this query should be normal as well.
I wrote an insert query for each type, so I have four queries using the following SQL:
I change the bolded ID number, as appropriate for each query.
This generates several rows. The telphone number appears below the appropriate telephone type column heading.
I need to generate a single row for each patient, instead of several rows.
It seems to me that since combo boxes are so normal, writing this query should be normal as well.
Code:
PATIENT PATIENT TELEPHONE TELEPHONE TYPE PatientID PatientTelephoneID TelephoneTypeID TelephoneNumber Description TelephoneType PatientID TelephoneTypeID Description 1 Office 2 Home 3 Fax 4 Cell
Code:
INSERT INTO PrintPatientTelephones ( PatientTelephoneID, PatientID, TelephoneTypeID, Office ) SELECT PatientTelephone.PatientTelephoneID, PatientTelephone.PatientID, PatientTelephone.PatientTelephoneType, PatientTelephone.TelephoneNumber FROM Patient INNER JOIN PatientTelephone ON Patient.PatientID = PatientTelephone.PatientID GROUP BY PatientTelephone.PatientTelephoneID, PatientTelephone.PatientID, PatientTelephone.PatientTelephoneType, PatientTelephone.TelephoneNumber, PatientTelephone.PatientTelephoneType HAVING (((PatientTelephone.PatientID)=[Forms]![frmProcessPatientReferral].[txt67]) AND ((PatientTelephone.[B]PatientTelephoneType)=2[/B])) ORDER BY PatientTelephone.PatientID;
This generates several rows. The telphone number appears below the appropriate telephone type column heading.
I need to generate a single row for each patient, instead of several rows.
Comment