Form Print Report on Selected Criteria

  • Thread starter Thread starter Robin
  • Start date Start date
R

Robin

What's the best way to do the following?

If users keys in "smith" for for it will display
all "smith" record and I want to have a button on this
form that will print a report for the one selected.

I tried to to create link criteria, but I've got something
wrong. Here's the code. Can someone tell me if there's a
better way and/or what I'm doing wrong???

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "rptByLName"
stLinkCriteria = [LName] = Me![LName]

DoCmd.OpenReport stDocName, acPriview, , stLinkCriteria
 
Robin,

It is very difficult to diagnose a problem or suggest solution(s) when you
say "something wrong".

Are you getting an error message when you attempt to run the report? If so,
what is the error message?

You may be getting an error message because of the following line of code:

stLinkCriteria = [LName] = Me![LName]

Since Me![LName] contains text, you must pass quotation marks around it, as
follows:

stLinkCriteria = [LName] = & Chr(34) & Me![LName] & Chr(34)

Or, is the problem that your report does display but that you are not
getting the desired result? If you are trying to get your report to print
data for *one particular person named "smith"*, then you will have to
provide a where clause that identifies the record by some unique field other
than LName.
 
Thank you. The report is opening with ALL records. I will
try pulling record by member#. Thanks again and I'll try
to be clearer next time.
-----Original Message-----
Robin,

It is very difficult to diagnose a problem or suggest solution(s) when you
say "something wrong".

Are you getting an error message when you attempt to run the report? If so,
what is the error message?

You may be getting an error message because of the following line of code:

stLinkCriteria = [LName] = Me![LName]

Since Me![LName] contains text, you must pass quotation marks around it, as
follows:

stLinkCriteria = [LName] = & Chr(34) & Me![LName] & Chr(34)

Or, is the problem that your report does display but that you are not
getting the desired result? If you are trying to get your report to print
data for *one particular person named "smith"*, then you will have to
provide a where clause that identifies the record by some unique field other
than LName.



--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


What's the best way to do the following?

If users keys in "smith" for for it will display
all "smith" record and I want to have a button on this
form that will print a report for the one selected.

I tried to to create link criteria, but I've got something
wrong. Here's the code. Can someone tell me if there's a
better way and/or what I'm doing wrong???

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "rptByLName"
stLinkCriteria = [LName] = Me![LName]

DoCmd.OpenReport stDocName, acPriview, , stLinkCriteria


.
 
Back
Top