473,660 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11399
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("M1234567 8",Me!bxDistriC de) 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("M1234567 8", 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
24023
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 tables in the database where the code resides. If we move the database with the data tables to a new directory, the links are no longer valid. I tried to update the links by changing the Connect property and refreshing: Set td = db.TableDefs(0)...
1
4007
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 live databases on the network. Is there a way, via code, when I get back in-house from being on the road to click a button, and select the backends I want to link to? I would want to delete all the current links and link to the "live"
10
12292
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 database table using INSERT.... (field1) ...VALUES ......... (N'Characters'). How do I do this using Rs.Update viz-a-viz:
6
4342
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 I should post it. I have created a form, which consists of a list of items, each with a checkbox. When a checkbox is checked or unchecked, the page should be refreshed. During the refresh, the data is validated and the MySQL database is...
1
3994
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 am trying to update a contact record with FirstName and LastName contained on a table TblContacts via a Combo Box using the Limit to List function to add new contacts and perform a search to check if the contact is new or already exists on the...
13
12787
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 scripting language that makes writing automated tests simpler. Really, I'm looking to kind of abstract the power of the C# language into a simpler language that's easier to learn. The script files would be interpreted by a script interpreter...
11
15275
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 name=type..in the form of array..but on checking it the result in the database simply gives the world 'array'.i want multiple checkboxes to be checked and updated simultaneously.. and the query to insert the checkbox value has to be included along with...
4
6492
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 retrieved using list/menu box. When i check only a single checkbox to insert the checked category ,selecting that category through list box gives out the entire data of the user corresponding to that category. However when i check multiple checkboxes and...
17
2223
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' is not assigned 'dMax' This is my first steps in C#: i can't manage(understand) this error. I would like to test to variables which can be change on form1 by 2 numeric updown controls before sending them to a UserControl which make some...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.