Printing 2 reports for 1 ID

  • Thread starter Thread starter Damian
  • Start date Start date
D

Damian

It seems to me like this shouldn't be as difficult as it
is, but I'm trying to print out two reports with the same
ID field. I want the user to be prompted for the ID number
once, then have both reports print out based on that input.
It seems to me that this should work:

Dim Message, IDnum As String
Dim ReportA, ReportB As String

ReportA = "rpt_first"
ReportB = "rpt_second"
Message = "Please enter ID number."
IDnum = InputBox(Message)

DoCmd.OpenReport ReportA, acViewNormal, , _
[key_ID] = IDnum
DoCmd.OpenReport ReportB, acViewNormal, , _
[key_ID] = IDnum

but when I try to run it I get the error message "can't
find the field '|' referred to in your expression"
(runtime error 2465) on the Openreport command. I can't
figure out what field they're talking about.

Any ideas?

Damian
 
It seems to me that this should work:
Dim Message, IDnum As String
Dim ReportA, ReportB As String

ReportA = "rpt_first"
ReportB = "rpt_second"
Message = "Please enter ID number."
IDnum = InputBox(Message)

DoCmd.OpenReport ReportA, acViewNormal, , _
[key_ID] = IDnum
DoCmd.OpenReport ReportB, acViewNormal, , _
[key_ID] = IDnum

but when I try to run it I get the error message "can't
find the field '|' referred to in your expression"
(runtime error 2465) on the Openreport command. I can't
figure out what field they're talking about.

Any ideas?

Damian

I'm not sure if this is causing your problem, but unless
something has changed since I learned about the Dim
command, you should type each variable explicitly, i.e.,

Dim Message As String, IDnum As String
Dim ReportA As String, ReportB As String

otherwise, previous others in the list will be typed
Variant.

Kevin Sprinkel
Becker & Frondorf
 
Kevin,
I corrected my declarations but it doesn't change the
error message I get when I run the code.
Any other suggestions?

Damian
-----Original Message-----
It seems to me that this should work:

Dim Message, IDnum As String
Dim ReportA, ReportB As String

ReportA = "rpt_first"
ReportB = "rpt_second"
Message = "Please enter ID number."
IDnum = InputBox(Message)

DoCmd.OpenReport ReportA, acViewNormal, , _
[key_ID] = IDnum
DoCmd.OpenReport ReportB, acViewNormal, , _
[key_ID] = IDnum

but when I try to run it I get the error message "can't
find the field '|' referred to in your expression"
(runtime error 2465) on the Openreport command. I can't
figure out what field they're talking about.

Any ideas?

Damian

I'm not sure if this is causing your problem, but unless
something has changed since I learned about the Dim
command, you should type each variable explicitly, i.e.,

Dim Message As String, IDnum As String
Dim ReportA As String, ReportB As String

otherwise, previous others in the list will be typed
Variant.

Kevin Sprinkel
Becker & Frondorf
.
 
Back
Top