Solved

Open Report , Where condition

Posted on 2013-05-26
7
1,308 Views
Last Modified: 2013-05-27
Experts, how do I open the report with the where condition below?  There is an error on the bold part.   thank you

Private Sub Command74_Click()

    Minimize
    DoCmd.OpenReport "rptQry_FX_Expected", acViewPreview,,[Status] Not Like "*Dead*" And Not Like "*lost*" And Not Like "*Award*" And Not Like "*Won*"

End Sub
0
Comment
Question by:pdvsa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 27

Assisted Solution

by:jjafferr
jjafferr earned 385 total points
ID: 39197993
you can put it in the query that the Report is based on, if the Report is based on a Table, then make a query for it, and put this condition as a criteria under the [Status] field.

the option it to insert it in the Report's Filter.

jaffer
0
 

Author Comment

by:pdvsa
ID: 39198004
Hi jaffer and thanks for the response. actually I do have it this way (where condition in the query) and I want to open the report a more dynamic way by having the where condition in the button instead of the query.   I have a few different buttons on the form and each has its own where condition criteria.  

What do you think now?  thank you
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 39198018
so you want to use one query, yet have different buttons on the Form, each with a different condition (Filter ing the query further),
In this case, one way to do this is by using the query as is, and using the Report Filter for the further "Filtering".

Assuming your command button event is as you mentioned above:

Private Sub Command74_Click()

    Minimize
    DoCmd.OpenReport "rptQry_FX_Expected", acViewPreview
    Reports!rptQry_FX_Expected.Filter="[Status] Not Like '*Dead*' And [Status] Not Like '*lost*' And [Status] Not Like '*Award*' And [Status] Not Like '*Won*'"
    Reports!rptQry_FX_Expected.FilterOn=true

End Sub

Open in new window


You just have to check your Where condition syntax, and the query is the best place to fine tune it.

jaffer
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:pdvsa
ID: 39198025
ahhhh...I see ....I have never used that before.  Looks nice.   I will test in a couple hours.  I am sure that is what I am looking for though.
0
 
LVL 27

Accepted Solution

by:
jjafferr earned 385 total points
ID: 39198031
Please allow me to show you how I do it :)

Open any Form, in the Design view, look at the Form's properties > Filter,
it should be empty,
Now switch to Layout view, right click on one of the field values, and select "equals to",
now go back to the design view and see what the Form Filter property is :)
add another Filters to it, and see the Filter, .... and so on,
now you can use that in your Report :)

For your case, look for "Does not contain", which might help you build your Filter :)
and you can use the wildcat '*'  (without the quotes) too (assuming you are using access 2007 or greater (that is for the "Does not contain").


jaffer
0
 

Author Closing Comment

by:pdvsa
ID: 39199626
very nice!  thank you for the explanation too.  I wrote that down.
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 39199631
you are welcome, and thanks for the points and grade :)

jaffer
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Runtime Error -2147467259 (80004005) 7 50
Null or "" 28 53
MS Access VBA Text String Missing From The End Of A String After Stream 8 50
How do a DCount on a report 1 18
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question