473,408 Members | 2,832 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.

access query misses data criteria

This is the code that i put into the SQL screen.
the data is as follows
BS 1 = 80
BS 2 = 101
BS 3 = 20
BS 4 = 100

and the query asks me for the Blood Sugar Level.
If i use numbers below 80, or 100 and up it works correctly. but if i put in 83,87,95,99, etc between 80 and 100 it shows 0 results even though it should still show the results from above.
what am i missing?

Expand|Select|Wrap|Line Numbers
  1. SELECT [Contact Info].ID, [Contact Info].[First Name], [Contact Info].[Paternal Last Name], [Contact Info].[Maternal Last Name], [Contact Info].DOB, BS.[BS 1], BS.[BS 2], BS.[BS 3], BS.[BS 4]
  2. FROM BS INNER JOIN [Contact Info] ON ([Contact Info].ID = BS.ID) AND (BS.ID = [Contact Info].ID) AND (BS.ID = [Contact Info].ID)
  3. WHERE 
  4. (((BS.[BS 1])>=[Blood Sugar Level])) OR (((BS.[BS 2])>=[Blood Sugar Level])) OR (((BS.[BS 3])>=[Blood Sugar Level])) OR (((BS.[BS 4])>=[Blood Sugar Level]))
Mar 17 '11 #1

✓ answered by TheSmileyCoder

Hi Joe

I have tried looking at it, and can't find any obvious issues. Have you tried placing a parenthesis around the 4 or statements (The where criteria)?

Also why do you join the tables 3 times? I would think 1 time should suffice just fine :P

6 2113
TheSmileyCoder
2,322 Expert Mod 2GB
Hi Joe

I have tried looking at it, and can't find any obvious issues. Have you tried placing a parenthesis around the 4 or statements (The where criteria)?

Also why do you join the tables 3 times? I would think 1 time should suffice just fine :P
Mar 17 '11 #2
smiley,
thanks for the insight and oops...i cheated and used the query builder to build it for the beginning part so it for some reason joined them 3 times.

but i figured it out. i had the field property set to "text" instead of "number" for all those fields, so it was reading 83 as higher than 100 because the first digit is higher...
Mar 17 '11 #3
TheSmileyCoder
2,322 Expert Mod 2GB
Ah, good you could spot that. I read and reread your sql before my first post and couldn't find anything wrong, besides the triple join.
Mar 17 '11 #4
NeoPa
32,556 Expert Mod 16PB
Joe Farage:
thanks for the insight and oops...i cheated and used the query builder to build it for the beginning part so it for some reason joined them 3 times.
Actually, using the Query Builder is an intelligent way to proceed and start learning SQL.

That said, the Query Builder isn't stupid either, so if you have the JOIN set up with three identical pairs of fields compared (as you have) then you're doing something wrong there. That may be in your table design (look particularly at how relationships are set up), or it may be in your use of the Query Builder itself. Either way, such mistakes may go unnoticed for a while, but they should never be considered unimportant. It's almost guaranteed that they will come back and bite you on the bottom. I strongly recommend you find and fix.

Best wishes.
Mar 20 '11 #5
TheSmileyCoder
2,322 Expert Mod 2GB
I use the query builder myself to START 95% of my SQL statements. Then I might switch to "pure" sql view, copy the SQL syntax into my VBA editor and make small modifications (Like parsing variables into the SQL).
Mar 21 '11 #6
NeoPa
32,556 Expert Mod 16PB
Sure. I do too for the more involved queries. I'm not so stupid I want to do all that detailed work with my fingers ;-)
Mar 21 '11 #7

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

Similar topics

0
by: MLH | last post by:
I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the selections made in a number of criteria choices on a form, a field on the form will have string...
4
by: ShastriX | last post by:
Getting a weird error while trying out a query from Access 2003 on a SQL Server 2005 table. Want to compute the amount of leave taken by an emp during the year. Since an emp might be off for...
5
by: redstamp | last post by:
Try as I might I cannot find a way to write an access query to return a result set with the records from my database WITHOUT a certain set of values within a field. To explain, I have a table of...
12
by: zwasdl | last post by:
Hi, I'm using MS Access to query against Oracle DB via ODBC. Is it possible to use HINT in Access? Thanks, Wei
19
MSeda
by: MSeda | last post by:
I would like to use a Global variable as a criteria in an access query. in my first attempt to do so I wrote a Function that looks like this Public Function GloVar(ByVal VarName) As String ...
6
by: Matsam | last post by:
Hi, I am using ADODB connection in ASP and want to run a select query depending on a runtime criteria. But its not working and giving error "Too few parameters. Expected 1." But the same thing is...
1
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
1
by: Joban | last post by:
Hiah i need to set a data range on the Product Query. Basicly the criteria should let me choose a data range between to values for the the Unit cost Field so i want it to show selected...
6
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
15
by: OzNet | last post by:
I have a query (with calculated fields) in Access (2007) and the data changes depending on the dates and staff person selected. I need to produce a series of graphs based on the data in this query...
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: 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: 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
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,...
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
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...
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.