Solved

Multi Where clause

Posted on 2013-12-31
3
244 Views
Last Modified: 2013-12-31
Hi,
I am trying to open a report based on a where clause depending on what the user selects in an optionframe on a form.

I have looked through here and google but I am getting more and more confused.
It works if I select an option with a single number behind it, but not with the two numbers. (the numbers are primary keys for the customers).

Any help is appreciated.
Thanks
Dim strWhere As String
Dim Cust As Integer

Select Case Me.frameProdGroup
    Case 1
        Cust = 300 Or 169
    Case 2
        Cust = 444 Or 329
    Case 3
        Cust = 238
    Case 4
        Cust = 220
    Case 5
        Cust = 235
    Case 6
        Cust = 180
End Select

strWhere = "[fkCustID] = " & Cust
DoCmd.OpenReport "rptStoxBase", acViewReport, , strWhere

Open in new window

0
Comment
Question by:Stephen Byrom
[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
  • 2
3 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39748615
Try this:

Dim Cust As as string

Select Case Me.frameProdGroup
    Case 1
        Cust = "IN (300,169)"
    Case 2
        Cust = "IN (444,329)"
    Case 3
        Cust = " = 238"
    Case 4
        Cust = " = 220"
    Case 5
        Cust = " = 235"
    Case 6
        Cust = " = 180"
End Select

strWhere = "[fkCustID]  " & Cust
DoCmd.OpenReport "rptStoxBase", acViewReport, , strWhere
0
 
LVL 1

Author Closing Comment

by:Stephen Byrom
ID: 39748648
Perfect!
Thanks for your time, you've saved me loads
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39748656
glad I could help.

Happy New Year!
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

726 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