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

Why does zero not equal zero in my update query in Access?

In Access, I have a table that receives data from Excel. I have a second table that has one of its fields changed based on a comparison to the first table. The update query is as follows:

Expand|Select|Wrap|Line Numbers
  1. UPDATE OpenReqs 
  2. LEFT JOIN DownloadedReqs 
  3. ON (([OpenReqs].[SUF]=[DownloadedReqs].[SUF]) 
  4.     Or ([OpenReqs].[SUF] Is Null)) 
  5.   AND (([OpenReqs].[DOC NO]=[DownloadedReqs].[DOC NO]) 
  6.     And ([OpenReqs].[STOCK NO]=[DownloadedReqs].[STOCK NO])
  7.     And ([OpenReqs].[QTY]=[DownloadedReqs].[QTY]) 
  8.     And ([OpenReqs].[TRR]=[DownloadedReqs].[TRR])) 
  9. SET OpenReqs.SHIPPED = Yes
  10. WHERE (([DownloadedReqs].[DOC NO]) Is Null);
  11.  
This works like a charm as long the QTY values in both tables are non-zero. If both tables have a zero value, it returns false and marks as shipped. Why does zero not equal zero? There does not seem to be a rounding error either (I've looked at the Excel data out to 35 decimal places, and there are no calculations performed on the QTY value). I've tried text and number data types in Access, and I've tried changing the data types in Excel to match the Access fields before the import. No dice. What am I missing?

Thank you.
Nov 2 '10 #1
6 3929
code green
1,726 Expert 1GB
Are you sure the values are zero and not empty or NULL?
Nov 2 '10 #2
Values in the source Excel workbook are 0. And when I open the table in Access (Access 2007) using DataSheet view, I can filter for 0 in the QTY field. I can select "equals 0", "does not equal 0", etc., so I'm assuming it's being recognized as a zero. If both tables' QTY values are 1, 2, 3 ... n, they are correctly NOT marked shipped, but if both tables have a zero (0), they are marked shipped. I don't have any kind of validation/formatting requirements on the field from what I see in the field properties.

Thanks for helping.
Nov 2 '10 #3
NeoPa
32,556 Expert Mod 16PB
Considering what you've already told us this is a long-shot, but have you confirmed all the xeroes are actually numeric zeroes and not string zeroes? I normally tell the difference by ensuring the Horizontal Alignment is set to General. That separates the wheat from the chaff.

As I say - a long-shot - but I hope it's some help :-)
Nov 2 '10 #4
code green
1,726 Expert 1GB
This worries me
I've looked at the Excel data out to 35 decimal places
It suggests a floating point value.
You cannot ever, ever, ever compare one or more floating point numbers.
This is down to how a float is represented and is a full lesson in computer science.

The fact you get away with it when not zero may be a fluke.
I apologise if there is no float in there, but if so you either need to
Expand|Select|Wrap|Line Numbers
  1. CAST or CONVERT [OpenReqs].[QTY] and[DownloadedReqs].[QTY] to INT.
Another way is subtract the two and compare to a tolerance.
Expand|Select|Wrap|Line Numbers
  1. And (([OpenReqs].[QTY]-[DownloadedReqs].[QTY]) < EPSILON)
where EPSILON is something like 0.00001.

Like I said, this is a big subject but it still trips a lot of people up (including me)
Nov 2 '10 #5
code green,
I used your first method and it works. Thanks! Perhaps the Excel data is casuing a floating point issue..
NeoPa, I'm almost sure they were not string (but I was doubting everything I was seeing on the screen).
Thanks to you both for the replies and successful assistance. Cheers!
Nov 2 '10 #6
NeoPa
32,556 Expert Mod 16PB
If that method worked for you then I'm pretty sure it's not string related too. It was a thought - that just happened to be wrong in this case. Luckily Code Green stepped up to sort you out. That's how it goes sometimes :-)
Nov 3 '10 #7

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

Similar topics

1
by: Travis | last post by:
I am in the process of building an application that lists several orders on one table with various info to some other tables with other info relating to these orders and access this via .asp. I...
5
by: Brandon Mackie | last post by:
I am incredibly new to access and trying to learn as I go. I have set up a few queries one of which is executed by a docmd.runsql in visual basic. Because it is an update query it asks for...
5
by: Andrew | last post by:
I've got a list box that selects a record on a subform, and in that subform are a few text fiels and a button that runs an update query. How do I have the update query button run and only update...
6
by: ralph_noble | last post by:
Can someome please advise what the equivalent query would be in Microsoft SQL Server ... I've tried a number of combinations with no success ... Thanks, Ralph Noble (ralph_noble@hotmail.com) ...
2
by: NigelMThomas | last post by:
I have an especially challenging problem. I know there are a few geniuses in this group so perhaps; you can advise me whether or not this can be done as an update query in Access. Thanks. I am...
9
by: pandaking | last post by:
Hi there everyone, new here but after reading around it seems like I might hang about - so many helpful threads! I have a slight problem. This flying club near me has employed me to make them a...
6
JKing
by: JKing | last post by:
I'm using an update query to update a single field in a table. Table1 is part of my normalized table structure. Table2 is used solely as an import table for raw data which I sort and summarize...
3
by: fperri | last post by:
I have a field in my main table called "CHANGE". Each week before we update the data we create a backup of the table and adjust the CHANGE field for all records to zero. I have an update query where...
3
by: javakid | last post by:
Hi MySQL Gurus, I have a query as in following format: update tbl1, ( subquery )as tbl2 set tbl1.col1 = IFNULL(tbl2.col1,0) where tbl1.col2 = tbl2.col2Here, Actually i am returning a...
4
by: anniebai | last post by:
Update contacts set Commonsid = (select Commonsid from contacts1 where contactid = contacts.contactid and Commonsid is not null) where Commonsid is null This query gives 'Operation must use an...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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
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
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.