Solved

MSAccess/VBA/DAO query result set not as expected

Posted on 2007-11-20
3
1,936 Views
Last Modified: 2013-11-27
I have an application that I have to support that was written in MS-Access 2003 VBA with DAO access to ODBC PostgreSQL database tables.

The database was designed without the use of "no nulls" capability of PostgreSQL so a varchar field without valid data could be null, blank or space.

The db.OpenRecordset query is supposed to select all records where a particular varchar field (RecordType) is null, space or blank, but it is not selecting the null fields into the result set.  Can anyone see what might be wrong with the code snippet or suggest an alternative to ensure that nulls are included in the result set?

Please don't suggest changing it to ADO.  This system is in maintenance mode - I have better things to do with my time than rewriting old code.  I just need the result set to be as expected.
Set db = CurrentDb
Set rs = db.OpenRecordset("select * from <tablename> where [supplier] = 'name' and ([RecordType] = null or [RecordType] = '' or [RecordType] = ' ') order by [Sys_ID]")

Open in new window

0
Comment
Question by:ShineOn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
GeraldHlasgow earned 500 total points
ID: 20321164
I'm not familiar with PostgreSQL so this is just a guess, but on most SQL databases that I've used if you want to check for a field being null you say

WHERE [FieldName] IS NULL

and not

WHERE [FieldName] = Null

Just a thought...
0
 
LVL 35

Author Comment

by:ShineOn
ID: 20321431
Thanks.  I didn't catch that.  

IS NULL is proper for PostgreSQL - it uses standard SQL.  

Sometimes it takes a second set of eyes... ;)
0
 
LVL 1

Expert Comment

by:GeraldHlasgow
ID: 20321477
Happy to lend an eye or two :-)
0

Featured Post

Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question