-1

I have an access form that contains an Id field.Once a user enters the Id , i want to run a query on the after update event to get the patients history field and display it as a msg box.

The query is as follows :

"Select Patients.[Patient History] From Patients Where Patients.ID = " & Me.PatientID

How can i do this?

thank you

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Abdalla Ismail
  • 409
  • 1
  • 4
  • 21
  • See this question and answer: http://stackoverflow.com/questions/23992226/how-to-save-the-result-of-a-sql-query-into-a-variable-in-vba – tlemaster Dec 18 '16 at 18:00

1 Answers1

1

You can use DLookup in a one-liner:

MsgBox Nz(DLookup("[Patient History]", "Patients", "ID = " & Me!PatientID.Value & "")), vbInformation + vbOkOnly, "Patient History"
Gustav
  • 53,498
  • 7
  • 29
  • 55