473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

using if to check for multiple values

Hi All,
In access97 is there a way to check for multiple values in an if
statement like this

If Me!bxDistriCde <> "m" Or 1 Or 2 Or 3 Or 4 Or 5 Or 6 Or 7 Or 8 Then
or something like this
If Me!bxDistriCde <> ("m", 1, 2, 3, 4, 5, 6, 7, 8) Then

or do I have to do it like this

If Me!bxDistriCde <> "m" Or me!bxDistriCde <> 1 Or me!bxDistriCde <> 2
etc...........
thanks
bobh.

Mar 14 '06 #1
4 11352
bobh wrote:
Hi All,
In access97 is there a way to check for multiple values in an if
statement like this

If Me!bxDistriCde <> "m" Or 1 Or 2 Or 3 Or 4 Or 5 Or 6 Or 7 Or 8 Then
or something like this
If Me!bxDistriCde <> ("m", 1, 2, 3, 4, 5, 6, 7, 8) Then

or do I have to do it like this

If Me!bxDistriCde <> "m" Or me!bxDistriCde <> 1 Or me!bxDistriCde <> 2
etc...........
thanks
bobh.

If Instr("M12345678",Me!bxDistriCde) Then
Mar 14 '06 #2
Hello, I don't think you can do it in an IF statement, but you can in a
SELECT CASE statement.

By the way, if you combine <> conditions, you probably want AND not OR:
If Me!bxDistriCde <> "m" AND me!bxDistriCde <> 1 AND me!bxDistriCde <>
2

Mar 14 '06 #3
You could play with this to make it do what you want, maybe.

Option Compare Binary

Sub AirCode(ByVal v As Variant)
Select Case v
Case 10 To 20
MsgBox "Between Ten and Twenty"
Case "a" To "z"
MsgBox "Lower Case"
Case DateSerial(1937, 12, 18) To DateSerial(1947, 12, 18)
MsgBox "Hmmmmm!"
Case Else
MsgBox "I dunno!"
End Select
End Sub

Sub test()
AirCode DateAdd("yyyy", -65, Date)
End Sub

Mar 14 '06 #4
Thanks All for your ideas on this and both these vba sets of code work

If InStr("M12345678", Me!bxDistriCde) Then
do whatever...........
End If

Select Case Me!bxDistriCde
Case "1", "2", "3", "4", "6", "7", "8", "m"
do whatever.................
End Select

thanks again
bobh.

Mar 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
10
by: Roger Withnell | last post by:
I'm using ASP, VBScript and SQL Server. I'm also using UTF-8 character set and so my codepage is 65001 and SQL Server datatype nvarchar. I can insert unicode characters correctly into the...
6
by: Daz | last post by:
Hi everyone. Firstly, I apologise if this i not what you would call a PHP problem. I get quite confused as to what lives in which realm, so if this shouldn't be posted here, please suggest where...
1
by: Jason Northampton | last post by:
Hello This is the first time I've used a discusion forum and up until now I have managed to use and or modify VB code from the various sites on the web, until now! This is a simple problem and I...
13
by: jkimbler | last post by:
As part of our QA of hardware and firmware for the company I work for, we need to automate some testing of devices and firmware. Since not everybody here knows C#, I'm looking to create a new...
11
by: TechnoAtif | last post by:
INSERT AND UPDATE MULTIPLE CHECKBOX DATA USING PHPMYSQL OR JAVASCRIPT Hi All I want to check the multiple checkboxes update them after revisiting that page. I am taking the name as...
4
by: TechnoAtif | last post by:
Hi ALL I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be...
17
by: Pascal | last post by:
hello everybody ! I get this error 3 times : "The output parameter must be assigned before the control leaves the current method" (dor dMin and dMax) this one 1 time : Use of the parameter 'out'...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.