report will not pull up info by primary key

G

Guest

Hi,

I have a command button on a form. The form brings up patient information
by a unique identifier called PatientID. The button calls open to preview
before printing a form a sheet of 30 labels. The problem, is that instead of
bringing up just a sheet for that one patient, it brings up a sheet of 30
labels for every patient.

any help would be appreciated. The code is below.

Private Sub cmdHCPatientLabel_Click()

DoCmd.OpenReport "HC_labels", acNormal, ,
"[forms]![frmPatients]![PatientID]=" & [PatientID]


End Sub
 
J

John Spencer

Try
DoCmd.OpenReport "HC_labels", acNormal, ,
"[PatientID]=" & [forms]![frmPatients]![PatientID]

If PatientID is a string field (and not a number field) then you need to add
text delimiters to the above

DoCmd.OpenReport "HC_labels", acNormal, ,
"[PatientID]=" & Chr(34) & [forms]![frmPatients]![PatientID] & Chr(34)
 
J

John Spencer

Is this a reply to my earlier posting?

If so, which of the suggested options did you use?


fascal said:
I get the message, "datatype mismatch in criteria expression".

fascal said:
Hi,

I have a command button on a form. The form brings up patient information
by a unique identifier called PatientID. The button calls open to preview
before printing a form a sheet of 30 labels. The problem, is that instead
of
bringing up just a sheet for that one patient, it brings up a sheet of 30
labels for every patient.

any help would be appreciated. The code is below.

Private Sub cmdHCPatientLabel_Click()

DoCmd.OpenReport "HC_labels", acNormal, ,
"[forms]![frmPatients]![PatientID]=" & [PatientID]


End Sub
 
G

Guest

I used the first one. I just get a print out of #Error ofr the label 4
times. The patient id shows when i pass my cursor over the code in VB. ANy
other ideas?

fascal

John Spencer said:
Is this a reply to my earlier posting?

If so, which of the suggested options did you use?


fascal said:
I get the message, "datatype mismatch in criteria expression".

fascal said:
Hi,

I have a command button on a form. The form brings up patient information
by a unique identifier called PatientID. The button calls open to preview
before printing a form a sheet of 30 labels. The problem, is that instead
of
bringing up just a sheet for that one patient, it brings up a sheet of 30
labels for every patient.

any help would be appreciated. The code is below.

Private Sub cmdHCPatientLabel_Click()

DoCmd.OpenReport "HC_labels", acNormal, ,
"[forms]![frmPatients]![PatientID]=" & [PatientID]


End Sub
 
J

John Spencer

So, is PatientID a text field or a number field. As I recall, the first option
was to handle number fields and the second was to handle text fields.

Also, is the field PatientID in the source for the Hc_Labels report?

To check that see if you can select PatientID as the source for a control. If
you can't you will need to add it to the report's record source - If I recall
correctly you don't have to assign it to a control on the report.
I used the first one. I just get a print out of #Error ofr the label 4
times. The patient id shows when i pass my cursor over the code in VB. ANy
other ideas?

fascal

John Spencer said:
Is this a reply to my earlier posting?

If so, which of the suggested options did you use?


fascal said:
I get the message, "datatype mismatch in criteria expression".

:

Hi,

I have a command button on a form. The form brings up patient information
by a unique identifier called PatientID. The button calls open to preview
before printing a form a sheet of 30 labels. The problem, is that instead
of
bringing up just a sheet for that one patient, it brings up a sheet of 30
labels for every patient.

any help would be appreciated. The code is below.

Private Sub cmdHCPatientLabel_Click()

DoCmd.OpenReport "HC_labels", acNormal, ,
"[forms]![frmPatients]![PatientID]=" & [PatientID]


End Sub
 

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