labels report not linking to identifier

G

Guest

I have a form that is based upon a unique identifier (PatientID). I have a
labels report, that I created, which prints 30 labels per page on Avery 5160
labels. The labels are based upon a query. The query runs fine.

The problem is that, no matter what code I have tried, I cannot get the
report to filter out the labels for the one person I request. When I open up
the report, and look at the properties, I can see on the control source line,
that it has filtered out the correct one, it just refuses to narrow it to one
patient on the physical report.

I ahve tried each of the following codes to see if either would have
success. Any help would be appreciated. Thx.

(code version 1)

Private Sub cmdHCPatientLabel_Click()
Dim strReportName As String
Dim strCriteria As String

strReportName = "HC_labels"
strCriteria = "[Forms]![frmPatients]![PatientID]='" & Me![PatientID] & "'"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria


End Sub
***************
(code 2)

DoCmd.OpenReport "HC_labels", acViewPreview, ,
"[Forms]![frmPatients]![PatientID]=" & Me!PatientID
 
A

Allen Browne

The first part of the critiera must refer to a field name in the report's
RecordSource, not to a text box on the form.

Try something like this:
strCriteria = "PatientID = " & Me.PatientID

If PatientID is a Text field (not a Number field):
strCriteria = "PatientID = """ & Me.PatientID & """"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top