473,383 Members | 1,892 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,383 software developers and data experts.

Using OR in Switch functions

I have an option group on a form with three choices "Yes/No/All" I'm
using a switch function in a query to filter records on a Yes/No field.
There is no problem displaying records that are either "Yes" or "No"
but when I try to display "All", using (-1 Or 0) in the switch
function, I only get the "Yes" records (-1). This is driving me nuts as
I'm sure I had it working and don't know what I changed. The criteria
in the field is as follows:

Switch([Forms]![frm RepJobsDue]![JobLive]=1,-1,[Forms]![frm
RepJobsDue]![JobLive]=2,0,[Forms]![frm RepJobsDue]![JobLive]=3,(-1 Or
0))

I can't see what the problem is, as having (-1 or 0) by itself in as
the criteria will display all records.

Nov 13 '05 #1
1 2500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

- -1 OR 0 is a binary OR not a logical OR. Any number binary OR'd with
zero will return that number. What you want to do is if JobLive = 3
then do nothing. Usually this situation calls for dynamically creating
the SQL string using VBA, 'cuz you are including/excluding a criteria
depending on user input. Something like this:
strSQL = "SELECT * FROM table_name "

If Me!JobLive = 1 Then
strWhere = "JobLive = True"
ElseIf Me!JobLive = 2 Then
strWhere = "JobLive = False"
Else
' do nothing, which will select ALL records
End If

If Len(strWhere)>0 then strSQL = strSQL & " WHERE " & strWhere

' do something w/ the SQL string.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQcMvIoechKqOuFEgEQJeUQCeO4jaNDPZvbfJMWmHVn64JJ lHZ8IAoJHW
yEMChdxjQ4WkgkrdZBELEVWN
=d9/5
-----END PGP SIGNATURE-----
wa****@4taconic.com wrote:
I have an option group on a form with three choices "Yes/No/All" I'm
using a switch function in a query to filter records on a Yes/No field.
There is no problem displaying records that are either "Yes" or "No"
but when I try to display "All", using (-1 Or 0) in the switch
function, I only get the "Yes" records (-1). This is driving me nuts as
I'm sure I had it working and don't know what I changed. The criteria
in the field is as follows:

Switch([Forms]![frm RepJobsDue]![JobLive]=1,-1,[Forms]![frm
RepJobsDue]![JobLive]=2,0,[Forms]![frm RepJobsDue]![JobLive]=3,(-1 Or
0))

I can't see what the problem is, as having (-1 or 0) by itself in as
the criteria will display all records.

Nov 13 '05 #2

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

Similar topics

4
by: Angelos | last post by:
Ok... I have to make this administation area where I have multiple Contents to add edit delete publish . The problem is that I don't know what is the best way of making the forms. At the moment I...
65
by: He Shiming | last post by:
Hi, I just wrote a function that has over 200 "cases" wrapped in a "switch" statement. I'm wondering if there are performance issues in such implementation. Do I need to optimize it some way? ...
14
by: Bryan Parkoff | last post by:
Do you know that current C++ Compiler limits to 64KB segments in source code? It is good news that Microsoft Visual C++ 2005 has expanded to 4GB segments in source code. 4GB segment is ideal for...
67
by: Rui Maciel | last post by:
I've been delving into finite state machines and at this time it seems that the best way to implement them is through an intense use of the goto statement. Yet, everyone plus their granmother is...
0
by: peridian | last post by:
Hi, I wanted a web page where I could post code to, and have it appear in coloured formatting based on the context of the code. Most of the techniques I have seen for this involve complex use...
6
by: asincero | last post by:
Which is better: using an if/else construct to simulate a C switch or use a dictionary? Example: def foo(): if c == 1: doCase1() elif c == 2: doCase2() elif c == 3: doCase3()
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
13
by: Albert | last post by:
Hi I'm using the lcc compiler for win32. I tried compiling a program but there's an error stating: "cpp: Can't open input file clrscr()" I don't get it - I've included <tcconio.h>. (strange why...
3
by: dizzy | last post by:
Hi I wonder if this code is standard conformant and should work on all conformant implementations (for some type T): 1: void* mem = ::operator new(sizeof(T)); 2: T* p = new(mem) T(args...);...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...

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.