Run report from form

  • Thread starter Thread starter Sarah at DaVita
  • Start date Start date
S

Sarah at DaVita

I have a form where each record has a doc_id. When comments are added to the
comment table this doc_id is used. I want to run a report from the form that
will only return items in the report that match the doc_id on the record the
user clicks on in the form. I tried the OpenReport method using me.doc_id =
doc_link_id (matching key in comment table that the report is getting its
data from) It errors. I know it must be something simple but everything I
tried errored out. Can someone help with this?
 
I have a form where each record has a doc_id. When comments are added to the
comment table this doc_id is used. I want to run a report from the form that
will only return items in the report that match the doc_id on the record the
user clicks on in the form. I tried the OpenReport method using me.doc_id =
doc_link_id (matching key in comment table that the report is getting its
data from) It errors. I know it must be something simple but everything I
tried errored out. Can someone help with this?

Do your self a favor. When posting code that you say you have done and
it doesn't work, always copy and paste the exact code into a message.
"using me.doc_id = doc_link_id" is certainly not correct, but it
might be that it is just because you wrote it here in your message and
it's not exactly the same as your code. This makes it difficult to say
what your problem is, and so we have to guess.
Also, in Access, field datatype is very important. Let us know the
datatype of criteria fields, in this case [doc_ID].

Your criteria data must be concatenated into the where clause
expression.
Assuming [doc_ID] is Number datatype, then try:

DoCmd.OpenReport "ReportName" acPreview, , "[doc_ID] = " & Me.[doc_ID]

See VBA help on the OpenReport method, as well as
"Restrict data to a subset of records"
to learn how to filter Number, Text and Date datatype fields.
 
Back
Top