Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Multi Where clause

Posted on 2013-12-31
3
Medium Priority
?
251 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
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Dale Fye earned 2000 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 49

Expert Comment

by:Dale Fye
ID: 39748656
glad I could help.

Happy New Year!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

916 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