I’m looking for a way to show my SQL results in a msgbox.
I am able to show 1 value, the first match, in the msgbox but I would like to have the whole list. Which is approx. 5 rows. This is the code I am using now
Code:
Private Sub btCPCT_Click()
Dim a As String
Dim b As DAO.Recordset
Dim patientnm As String
patientnm = patientnm & ", '" & Me.txPatientID & "'"
patientnm = Right(patientnm, Len(patientnm) - 1)
a = "SELECT Patient_name, Sample_name " & _
"FROM tblSamples " & _
"WHERE Patient_name IN (" & patientnm & ")" & _
"AND Source = 'Blood'" & _
"ORDER BY Sample_name DESC"
Set b = CurrentDb.OpenRecordset(a)
msgBox b.Fields("Sample_name")
b.Close
End Sub
So me.txtpatient is the value I am searching in the main table tblsamples the result of this search ar multiple samples names (Sample_name). With this code it only shows 1 sample and I want it to show all the sample names which match the entered patient ID
Hope it's possible XD