473,406 Members | 2,956 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,406 software developers and data experts.

Access query does not retrieve all records. Works fine in SQL Server.

Hi,

I am stuck with a problem in MS Access which does not occur in SQL
Server and I have been banging my head against the wall for a couple of
days now trying to resolve it. Namely, when I execute the following
query in Access not all records that fit the condition are returned,
and when I run this same query in SQL Server all the records I want are
retrieved.

The query is:

SELECT Events.nAsset, Events.nTime,
DickeyJohnController.nActualApplicationRate, Events.nAddress1
FROM Events, DickeyJohnController
WHERE Events.nTime >= #2007-01-05 16:47:00# AND Events.nTrimWebEventID
= DickeyJohnController.nTrimWebEventID
ORDER BY Events.nTime

In SQL Server this query is the same except for the ' character instead
of the # for dates.

Interestingly enough removing the time condition from the where clause
also does not return all expected records. It looks like the join is
the problem but I don't see what's wrong. There are no null values
among the nTrimWebIDs in either table.

I must be missing something very obvious. Your help is greatly
appreciated!

Mrdjan

Here are some details about the setup:

The query is hardcoded in a VB .NET application that connects to any
ODBC compliant DB. I just change my connection string and can run
either Access or SQL Server.
The data types in the MS Access database are as follows:
Events table:
nTrimWebEventID ------ Primary key, Long Integer, Required
nAsset Text, Not Required
nTime Date, Required
nAddress1 Text, Not Required

DickeyJohnController table
nTrimWebEventID ------ Primary key, Long Integer, Required
nActualApplicationRate Double, Not Required

By way of comparison, the SQL Server setup is as follows:

Events table:
nTrimWebEventID ------ Primary key, bigint, doesn't allow nulls
nAsset varchar(50), allows nulls
nTime datetime, does not allow nulls
nAddress1 varchar(50), allows nulls

DickeyJohnController table
nTrimWebEventID ------ Primary key, bigint, not allow nulls
nActualApplicationRate float, allow nulls

Jan 10 '07 #1
1 3842
mr*****@hotmail.com wrote:
Interestingly enough removing the time condition from the where clause
also does not return all expected records. It looks like the join is
the problem but I don't see what's wrong. There are no null values
among the nTrimWebIDs in either table.
By "query in Access", you presumeably mean against an MS Jet database.
You are not using the correct ANSI format for the join. Try using the
excellent graphical MS Access query design view to do what you're doing.
You'll end up with something like:

SELECT
Events.nAsset,
Events.nTime,
DickeyJohnController.nActualApplicationRate,
Events.nAddress1
FROM
Events INNER JOIN DickeyJohnController ON Events.nTrimWebEventID
= DickeyJohnController.nTrimWebEventID
WHERE
Events.nTime >= #2007-01-05 16:47:00#
ORDER BY
Events.nTime
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Jan 10 '07 #2

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

Similar topics

9
by: Roar | last post by:
Hi! I have got 1 access 2000 DB, one simple search form, and 3 .asp pages (one for deleting a record, one for inserting a record and one for listing searchresults). Deleting records works fine,...
1
by: David | last post by:
Hi everyone. I have read every page that Google returns on this topic, but can't find anything that resolves my problem. Basically, I have an Access Database that does a number of different...
3
by: dk | last post by:
Hi all, Would appreciate some advice on the following: I am trying to speed up an Access database connected to a SQL Server back-end. I know I can use a pass-through query to pass the sql...
1
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
9
by: MacDermott | last post by:
I have an Access MDB which instantiates a class in a custom DLL, manipulates it for a while, then sets it equal nothing. The MDB does other things,too, and generally behaves itself as desired....
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
15
by: olle | last post by:
Hi folks. I learning asp.net and compare it with traditional asp and Access-developing. The issue is this one: 1/I have this Ms Acceess adp-project application that works fine on my Ms Sql...
5
by: Henning M | last post by:
Hi all, I having some problems with Access and selecting records between dates.. When I try this in access, it works fine!! "Select * from Bilag Where Mdates Between #1/1/2006# And...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
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
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,...

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.