What do I need to add/modify to this code to have txtDisease1 be populated with the results of strSQL? As of now the textbox populates with the SQL query. I'm sure it is a simple fix but for the life of me I can not find the answer.
Private Sub btnDNA_Click()
Dim strSQL As String
strSQL = "SELECT LastName From Patient WHERE PatientID = 1"
Me.txtDisease1.Value = strSQL
End Sub
strSqlis literally only the text "SELECT LastName From Patient WHERE PatientID = 1" and not the executed result of the query it describes. Using theDLOOKUPfunction as @Emi has suggested is the simpler approach for what you're trying to do here.