Solved

if digit is 1 Or 4 Or 7 Or 0

Posted on 2011-02-10
17
231 Views
Last Modified: 2012-05-11
I am trying the query below but it doesn't work. Can't remember how to do this.

something like this??
If intRDigit = In(1,4,7,0) Then

If intRDigit = 1 Or 4 Or 7 Or 0 Then
strtest = "A"
ElseIf intRDigit = 2 Or 5 Or 8 Then
strtest = "B"
Else
strtest = "C"
End If
0
Comment
Question by:Shawn
  • 6
  • 5
  • 4
  • +1
17 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 34867445
If intRDigit = 1 Or intRDigit = 4 Or intRDigit = 7 Or intRDigit = 0 Then
strtest = "A"
ElseIf intRDigit = 2 Or intRDigit = 5 Or intRDigit = 8 Then
strtest = "B"
Else
strtest = "C"
End If
0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34867455
You can also use this

If InStr(intRDigit, "1470") > 0 Then
    strtest = "A"
ElseIf InStr(intRDigit, "258") > 0 Then
    strtest = "B"
Else
    strtest = "C"
End If

Open in new window

0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 34867459
Or you could use Select Case -

SELECT CASE IntRDigit
   Case 1,4,7,0
      strtest = "A"
   Case 2, 5, 8
      strtest = "B"
   Case Else
      strtest = "C"
End Select
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34867465
Or use SELECT CASE

Select Case intRDigit
Case 1, 4, 7, 0
    strtest = "A"
Case 2, 5, 8
    strtest = "B"
Case Else
    strtest = "C"
End Select

Open in new window

0
 
LVL 1

Author Closing Comment

by:Shawn
ID: 34867498
brilliant. thank you for the choice :)

Shawn
0
 
LVL 75
ID: 34867504
One Line:

strtest = Choose(strtest + 1, "A", "A", "B", "C", "A", "B", "C", "A", "B")

mx
0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34867545
@Dbmx

This is both shorter, and correct, as long as intRDigit is >= 0
Your Choose options don't cover more than 0-8.

strtest = Left(Mid("AABCABCAB", intRDigit + 1, 1) + "C", 1)
0
 
LVL 1

Author Comment

by:Shawn
ID: 34867565
i actually used the select case.
the digits are 0-9. the else covers 3, 6 and 9.
0
 
LVL 1

Author Comment

by:Shawn
ID: 34867575
the actual strings are quite bit longer than strtest = "A".
0
 
LVL 75
ID: 34867578
"Your Choose options don't cover more than 0-8."
Either does your Accepted solution  - so what?

And your new solution uses two functions instead of 1 !

mx
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 34867593
> i actually used the select case.
So then why wasn't there at least a split?  I posted the select case option...
0
 
LVL 75
ID: 34867597
"Either does your Accepted solution  - so what?"
Never mind ... I see that it does.  
0
 
LVL 75
ID: 34867603
" I posted the select case option..."
Exactly ... First at that ...

mx
0
 
LVL 75
ID: 34867615
Still one line ... covering any number > 8:

strtest = Nz(Choose(strtest + 1, "A", "A", "B", "C", "A", "B", "C", "A", "B"), "C")

mx
0
 
LVL 1

Author Comment

by:Shawn
ID: 34867650
leew
>>So then why wasn't there at least a split?
originally I just tested them and gave out the points to the first correct answer.
afterwards I decided which one to use. sorry about that. If you really want I can see if I can't reopen to distribute the points.
0
 
LVL 75
ID: 34867667
Just a suggestion ... sometimes it's best to wait for a few posts, especially when it's clear there will be many possible solutions, some simpler than others :-)

mx
0
 
LVL 1

Author Comment

by:Shawn
ID: 34867676
good point. thx :)
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

810 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