Hi,
I am trying to get a Combo Box to display only unique values of the "ReferralID" column. However it does not seem to be working with the DISTINCT function. Any help would be great! Below is my SQL:
I am trying to get a Combo Box to display only unique values of the "ReferralID" column. However it does not seem to be working with the DISTINCT function. Any help would be great! Below is my SQL:
Code:
SELECT DISTINCT tblReferrals.ReferralID, tblDoctorName.DoctorLastName, tblReferrals.ReferralDate, tblReferrals.ReferralReason, tblReferrals.PatientID, tblReferrals.ClinicID, tblAppointments.StatusID, tblAppointments.AppointmentTypeID
FROM (tblDoctorName INNER JOIN tblReferrals ON tblDoctorName.DoctorID = tblReferrals.DoctorID) INNER JOIN tblAppointments ON tblReferrals.ReferralID = tblAppointments.ReferralID
WHERE ((([tblAppointments]![StatusID]=[Forms]![frmPatientSearch]![cboStatusSearch] Or [Forms]![frmPatientSearch]![cboStatusSearch] Is Null)=True) AND (([tblAppointments]![AppointmentTypeID]=[Forms]![frmPatientSearch]![cboAppointmentSearch] Or [Forms]![frmPatientSearch]![cboAppointmentSearch] Is Null)=True) AND (([tblReferrals]![ClinicID]=[Forms]![frmPatientSearch]![cboClinicSearch] Or [Forms]![frmPatientSearch]![cboClinicSearch] Is Null)=True) AND (([tblreferrals]![PatientID]=[Forms]![frmPatientSearch]![cboPatientSearch] Or [Forms]![frmPatientSearch]![cboPatientSearch] Is Null)=True));