Advertisement

07.02.2008 at 04:47PM PDT, ID: 23535496
[x]
Attachment Details

For Experts: Differences between VB and Jet expressions

Asked by harfang in Microsoft Access Database

Tags: Microsoft, Access

Hello experts,

This is not really a question, but rather a open thread for technical discussion. However, points will be awarded for good explanations and original examples (see below).

I just lost one day hunting a bug in an application I'm working on. I quickly found the origin, but at first failed to correct the bug by introducing a new one. Consider the following query.

    UPDATE Table1 SET OK=IIf(Something,True,False)

The idea: set the OK flag for those records where 'Something' is both not null and not zero. Note that a previous version using Nz() caused the original bug, which I'm not going into. I'm also not expanding on why I would want to store a derived information like this (it had to do with optimization; let's leave it at that).

The problem: IIf(), when interpreted by Jet, does not work *exactly* like VB's IIf(). Since we all know that Eval() implements Jet's expression evaluator, we can test the following from the immediate pane:

    ? IIf(0.1,True,False)
    True
    ? Eval("IIf(0.1,True,False)")
    0

For VB, 0.1 is of course 'True', being non-zero. But apparently, 0.1 is 'False' for Jet, meaning that the argument is probably first cast to a Variant Integer (or a Variant Boolean) before being evaluated.

Another such difference between VB and Jet can be discovered by comparing:

    ? 3 And 7
     3
    ? Eval("3 And 7")
    -1

This has already been discussed in a previous Expert thread: {http:/Q_22135795.html}. Other known differences are that Jet allows single quotes, does not parse VB type-definition characters, and implements additional SQL operators.

So, the questions are:

    * Can you explain why IIf() behaves differently between Jet and VB?

    * Is this a bug or a feature?

    * Do you have other examples of such differences?

The question is *not*:

    * How to make this query work as expected?

But if course, feel free to experiment and share if you want.

Cheers all!

Markus
(°v°)Start Free Trial
[+][-]07.02.2008 at 04:50PM PDT, ID: 21921790

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 04:54PM PDT, ID: 21921806

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 06:41PM PDT, ID: 21922138

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 06:44PM PDT, ID: 21922149

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.02.2008 at 07:00PM PDT, ID: 21922195

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.02.2008 at 07:03PM PDT, ID: 21922207

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 09:26PM PDT, ID: 21922679

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 09:59PM PDT, ID: 21922757

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 10:11PM PDT, ID: 21922786

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.02.2008 at 10:24PM PDT, ID: 21922833

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.03.2008 at 12:51AM PDT, ID: 21923476

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.03.2008 at 03:51AM PDT, ID: 21924110

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.03.2008 at 04:26AM PDT, ID: 21924328

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Access Database
Tags: Microsoft, Access
Sign Up Now!
Solution Provided By: cactus_data
Participating Experts: 6
Solution Grade: A
 
 
[+][-]07.03.2008 at 09:12AM PDT, ID: 21926864

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.03.2008 at 10:41AM PDT, ID: 21927588

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.03.2008 at 03:56PM PDT, ID: 21929996

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 02:23AM PDT, ID: 21931901

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 09:24AM PDT, ID: 21933859

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 09:55AM PDT, ID: 21933980

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 04:06PM PDT, ID: 21935189

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.06.2008 at 06:27PM PDT, ID: 21942294

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.06.2008 at 07:29PM PDT, ID: 21942481

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.06.2008 at 08:16PM PDT, ID: 21942590

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.06.2008 at 08:17PM PDT, ID: 21942594

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.19.2008 at 10:42PM PDT, ID: 22044675

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_Related_20080208