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

An SQL Statement gone wrong!

toxicpaint
I'm using visual studio 2005 with ASPX + VB and Access.

Can someone help me with this, please. What I want the SQL to do is display all closed audits. The problem is that only certain people are allowed to see certain audits. So I want people to only see closed audits where they have rights. This is done by a PersonID (stored in a session). The only other people who can see closed audits are Admin staff, who have an admin value of 1 (everyone else is 0 - also stored in a session). I can get the audits to come up for people's PersonID's, but how can I get it to produce the audits for people who have admin rights?

Here's my current SQL code:

SELECT audits.ID, audits.QuickName, audits.Status, Person.PersonID, Person.Admin FROM ((audits INNER JOIN allowed ON audits.ID = allowed.AuditNum) INNER JOIN Person ON allowed.PersonID = Person.PersonID) WHERE (audits.Status = 'Closed') AND (Person.PersonID = ?) OR (audits.Status = 'Closed') AND (Person.PersonID = ?) AND (Person.Admin = 1)
Jul 26 '07 #1
1 1181
Sorted!

SELECT audits.ID, audits.QuickName, audits.Status, Person.PersonID, Person.Admin

FROM ((audits INNER JOIN allowed ON audits.ID = allowed.AuditNum) INNER JOIN Person ON allowed.PersonID = Person.PersonID)

WHERE (Person.PersonID = ? OR ? = 1) AND (audits.Status = 'Closed')
Jul 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ole Hanson | last post by:
Hi Trying to access the users desktop items, I want to use the following method: string url = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop); But - the...
8
by: Brian Basquille | last post by:
Hello all, Bit of a change of pace now. As opposed to the typical questions regarding my Air Hockey game, am also working on a Photo Album which uses an Access Database to store information...
20
by: John Salerno | last post by:
I'm starting out with this: try: if int(text) 0: return True else: self.error_message() return False except ValueError: self.error_message()
1
by: John | last post by:
Hi When I try to resolve replication conflicts, first of all 'Microsoft Replication Conflict Viewer' gets stuck for 15-20 seconds then it gives the error 'There was an error trying to obtain...
2
by: Pixiee | last post by:
Hi, I have been trying to alter a blogger template from a 2 colum to a three. It looks just how I want it in FF but when I look in IE not only has the second sidebar slipped but also the main...
1
by: thermate | last post by:
diapers, wig, knife ... guys i am dying of laughter, someone help me ... Seems like the Neoconish spirit of Bush/Cheney has permeated the whole country thru the cell phones and cause the yanks...
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...
4
by: xand75 | last post by:
Hello, recently been working on a form to search an sql db, at the moment its a simple 3 fields but ive been unable to get the if statement working. all the code is below. #!/usr/bin/perl -w...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
9
by: lilly07 | last post by:
I have done few basic perl programming and after spending some time in debugging, I thought of getting some help from this forum. Please let me know whether my program has gone wrong. Basically I...
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...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.