Run Report on Criteria From Form

  • 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 said:
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


If LName is a Text field, then the value you're searching
for has to be in quotes:
stLinkCriteria = "[LName] = """ & Me![LName] & """"
 
Back
Top