title: Access report, populate label with results of query
body: <p>I have, what I think, is a pretty basic Access file, with a report.  The report is based off a query.  The query is:</p>
  
  <pre><code>SELECT * FROM dbo_NewPatient WHERE id=[Patient to view];
  </code></pre>
  
  <p>This works good, and prompts me for an id, I enter Id, and the results are the patient I want to see.  Now I want to build a report that is based on this query, but I want to create a label on the report, that populates data from the results, so I've got this code:</p>
  
  <pre><code>Private Sub Report_Open(Cancel As Integer)
      Label2.Caption = "Patient Name is " &amp; PatientName &amp; " his time in hospital is ... "
  End Sub
  </code></pre>
  
  <p>I want that "PatientName" variable to be the data returned from the query.  I've tried PatientName.Value, and PatientName.Text, but each time, i get an error message:</p>
  
  <pre><code> 'The expression you entered has a field, control, or property name that Microsoft Office Access can't find'.
  </code></pre>
  
  <p>I'm assuming it doesn't know what "PatientName" is, perhaps because when I double click to open the report, I'm not yet prompted for the [Patient to view] variable, so the code doesn't yet know what PatientName is.  How can I correct this, or is there a better way to go about this?</p>
  
  <p>Thanks!</p>