• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

Access : Print ONE record in a report (i.e. record in Form)


I have a form with a button.  I have an existing report.

When the form button is clicked I want to print a single A4 page that relates exclusively to the customer on the Form.  The field CustomerID is on both the Form and the Report.

I am struggling with the "WHERE" clause.  See cust and paste below.
I want one record on the report
...where the CustomerID on the form = the Customer ID on the report

(I raised this query earlier today in a more confusing manner!)a

Private Sub rptOrderConfirmation_Click()

   Dim sWhere As String
   '******  sWhere = "[CustomerID] ='" & CustomerID & "';"
      DoCmd.OpenReport "rptOrderDetails", acViewPreview, , sWhere

End Sub

Open in new window

Patrick O'Dea
Patrick O'Dea
2 Solutions
Dale FyeCommented:
If [CustomerID] is numeric, then it should look like:

sWhere = "[CustomerID] = " & me.CustomerID

Rey Obrero (Capricorn1)Commented:
try without the ";"

sWhere = "[CustomerID] ='" & CustomerID & "'"
Patrick O'DeaAuthor Commented:
Thanks All,
 got it now !
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now