-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
  • 963,270
  • 265
  • 3,804
  • 3,187
Abdalla Ismail
  • 419
  • 1
  • 4
  • 18
  • 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
  • 48,886
  • 6
  • 31
  • 51