By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,654 Members | 1,811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,654 IT Pros & Developers. It's quick & easy.

Simple OpenReport with WhereCondition help!

P: 11
I have a form. I want to put a button on the form that when clicked opens a report and that report shows only the queried requests that match the customer id from the form. I have tried using the Event Procedure onClick DoCmd.OpenReport but don't know the syntax to use to get the results I want.


My form name is Customer
My query is named HalfSheetQuery
The report it creates is called HalfSheetPrintOut
The matching field name is customer.customerid
Feb 14 '07 #1
Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,365
What you can do is create a query that returns the records you want using the value from the form. Then link the report to that query. And you just open the report and the report should reflect what's in the query.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Report Name", acViewPreview
Feb 14 '07 #2

NeoPa
Expert Mod 15k+
P: 31,487
If you want to restrict the records included in a report there is an extra parameter which gives that facility.
Expand|Select|Wrap|Line Numbers
  1. Dim strFilter As String
  2. strFilter = "[CustomerID]=" & Me!CustomerID
  3. Call DoCmd.OpenReport("HalfSheetPrintOut",acViewPreview,,strFilter)
Feb 14 '07 #3

P: 11
If you want to restrict the records included in a report there is an extra parameter which gives that facility.
Expand|Select|Wrap|Line Numbers
  1. Dim strFilter As String
  2. strFilter = "[CustomerID]=" & Me!CustomerID
  3. Call DoCmd.OpenReport("HalfSheetPrintOut",acViewPreview,,strFilter)

That is exactly what I needed! Worked like a charm. Thanks so much!
Feb 16 '07 #4

NeoPa
Expert Mod 15k+
P: 31,487
You're very welcome.
It's, after all, why we're here :)
Feb 16 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.