You have spaces in the report name. That can cause problems.
Try using square brackets around the name and see if that takes care of
the problem.
DoCmd.OpenReport "[rptProgress Notes]", acPrintPreview
If that works then you can add in the strWhere to the call to
OpenReport
as Duane suggested.
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
Steve wrote:
If I put the whole entry:
Dim strWhere as String
strWhere = "[ID]=" & Me.ID
DoCmd.OpenReport "rptProgress Notes", acPrintPreview
or just the last line
DoCmd.OpenReport "rptProgress Notes", acPrintPreview
I get the following when I click the button:
"Run-time error '2103'
The report name 'rptProgress Notes' you entered in either the property
sheet or macro is misspelled or refers to a report that doesn't
exsist."
I'm not putting it in a macro though, I'm putting it in the code
builder.
:
What happens if you remove the strWhere?
Dim strWhere as String
strWhere = "[ID]=" & Me.ID
DoCmd.OpenReport "rptProgress Notes", acPrintPreview
--
Duane Hookom
Microsoft Access MVP
:
The report is there. I can open it manually from the navigation
pane. I
can create a button that opens it with every record displayed. When
using the code you supplied, I have tried the report title with and
without spaces (it has spaces the way it is written on the report
itself). For some reason, I get an error saying it doesn't exsist or
that the name is misspelled (it is not) and an option to debug. When
it
opens the debug screen, everything looks like it should.
:
If the error suggested the report doesn't exist, what do you have
to
say about that?
--
Duane Hookom
MS Access MVP
The ID field is an autonumber generated by access.
I was trying to do this via macro. I realised what you put down
there
is
code, so I went at it that way, and what I get when I press the
button is an
error message that says the report doesn't exsist.
Do you know of a good reference site for setting this up step by
step?
:
Are you actually using code or a macro? You mention "Action
arguments" but
this doesn't sound like code.
Is the ID field numeric or text?
--
Duane Hookom
Microsoft Access MVP
:
Yes it is.
:
Is the ID field included in the Report's record source query?
--
Duane Hookom
Microsoft Access MVP
:
I'm entering that in the "Where condition" of the "Action
arguments" section.
And keep getting the message that "Access can't parse the
expression".
My primary key is "ID" the table is "Progress Notes" and the
report is
"Progress Notes"
Below is how I entered the info:
Dim strWhere as String
strWhere = "[ID]=" & Me.ID
DoCmd.OpenReport "rptProgress Notes", acPrintPreview, ,
strWhere
Am I putting it in the wrong place or writing it out wrong?
Thanks
:
I would use the command button wizard to create a button that
opens the
report. Then modify the code created by the wizard so that it
applies a WHERE
CONDITION in the DoCmd.OpenReport method:
Dim strWhere as String
strWhere = "[ProgNoteID]=" & Me.ProgNoteID
DoCmd.OpenReport "rptYourProgressNotes", acPrintPreview, ,
strWhere
This all depends on your report name as well as the primary
key
field and
datatype.
--
Duane Hookom
Microsoft Access MVP
:
Here is what I have:
I have a database for tracking therapy clients. Client data
is
in one table.
Therapy progress notes are in another with a one-to-many
relationship. I have
a form w/ subform set up to receive the data. I have a query
set up to tie
the two tables together and feed into a report.
(Tables/Forms
and Queries all
do what I want them to properly) Right now, the report
contains
data from
every client and progress note.
What I want is to be able to place a button on the subform
for
the progress
notes, so that when it is clicked it generates the report
with
just that
current entry instead of every single progress note in the
database.