Oracle and Access, DLookup not returning expected results.

Posted on 2005-03-20
Medium Priority
Last Modified: 2008-07-03
I'm using Access with Oracle, a DLookup I'm using is not returning expected results.

The DLookup below returns count=0 when it should return count = 1.

Me.txtUserExistsFlg = DCount("LoginName", "Users", "LoginName = '" & Me.txtUserName & " ' ")  <-- doesn't work

Note that the table "Users" points to the Oracle table.
Me.txtUserName in the debugger looks like this:  "wpeck", including the double-quote marks.

If I hard-code the DLookup to

Me.txtUserExistsFlg = DCount("LoginName", "Users", "LoginName = 'wpeck'") <-- works with literal 'wpeck'

then it works fine.

In Oracle the name is lowercase, wpeck.

Any ideas?
Question by:Alaska Cowboy
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
LVL 66

Accepted Solution

Jim Horn earned 300 total points
ID: 13588537
Hi williampeck,

I believe you have an extra space before the right single-quote mark.  Try this...
Me.txtUserExistsFlg = DCount("LoginName", "Users", "LoginName = '" & Me.txtUserName & "'")  
....  Me.txtUserName {ampersand}{space}{double-quote}{single-quote}{double-quote}{right parentheses}

Hope this helps.

Author Comment

by:Alaska Cowboy
ID: 13588555
Yes, you are correct, and that did the trick !

In Access, the extra space resolved itself, but Oracle took things too literally - it always does.

Thanks ! Time for bed . . .

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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 …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

741 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