Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Open Report , Where condition

Posted on 2013-05-26
7
Medium Priority
?
1,495 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 1540 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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 1540 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

604 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