Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-23-2008, 09:57 PM
Lars Brownie
 
Posts: n/a
Finding null

I have a query with criteria in 2 fields:
FieldA has criteria: [forms]![MyForm].[Field1]
FieldB had criteria: [forms]![MyForm].[Field2]

So I need an exact match on those 2 fields.

Field1 is never null but Field2 can be null. If Field2 is null then the
query should look for the Field1 criteria in FieldA AND for a null value for
FieldB. However, this is not working, I get no results. When field2 is not
null, it does work.

Can someone help me out?
Thanks, Lars


Reply With Quote
  #2 (permalink)  
Old 07-23-2008, 10:23 PM
Jeff Boyce
 
Posts: n/a
Re: Finding null

Null means "nothing there". Is part of the problem because you are trying
to compare to "nothing there"?

If you'll post the SQL statement of your query, the folks here would have a
few more clues to go on...

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Lars Brownie" <lars@brownie.com> wrote in message
news:g689fl$c1u$1@textnews.wanadoo.nl...
>I have a query with criteria in 2 fields:
> FieldA has criteria: [forms]![MyForm].[Field1]
> FieldB had criteria: [forms]![MyForm].[Field2]
>
> So I need an exact match on those 2 fields.
>
> Field1 is never null but Field2 can be null. If Field2 is null then the
> query should look for the Field1 criteria in FieldA AND for a null value
> for FieldB. However, this is not working, I get no results. When field2 is
> not null, it does work.
>
> Can someone help me out?
> Thanks, Lars
>



Reply With Quote
  #3 (permalink)  
Old 07-23-2008, 10:42 PM
Lars Brownie
 
Posts: n/a
Re: Finding null

> Null means "nothing there". Is part of the problem because you are trying
> to compare to "nothing there"?


Yes. Here is a shortened example:

SELECT MyTable.Member_Name, MyTable.Street, MyTable.HouseNrAddition
FROM MyTable
WHERE (((MyTable.Straat)=[forms]![MyForm].[Street]) AND
((MyTable.HousNr)=[forms]![MyForm].[HouseNrAddition]));

In a record of MyTable for instance, Street has value MyStreet and
HouseNrAddition has value Null. If the corresponding form fields have
similar values, there is no match. I tried several iif's but can't get it to
work. It does work when HouseNrAddition field on the form is not null.

Thanks, Lars

"Jeff Boyce" <nonsense@nonsense.com> schreef in bericht
news:O18E1KR7IHA.1196@TK2MSFTNGP05.phx.gbl...
> Null means "nothing there". Is part of the problem because you are trying
> to compare to "nothing there"?
>
> If you'll post the SQL statement of your query, the folks here would have
> a few more clues to go on...
>
> Regards
>
> Jeff Boyce
> Microsoft Office/Access MVP
>
>
> "Lars Brownie" <lars@brownie.com> wrote in message
> news:g689fl$c1u$1@textnews.wanadoo.nl...
>>I have a query with criteria in 2 fields:
>> FieldA has criteria: [forms]![MyForm].[Field1]
>> FieldB had criteria: [forms]![MyForm].[Field2]
>>
>> So I need an exact match on those 2 fields.
>>
>> Field1 is never null but Field2 can be null. If Field2 is null then the
>> query should look for the Field1 criteria in FieldA AND for a null value
>> for FieldB. However, this is not working, I get no results. When field2
>> is not null, it does work.
>>
>> Can someone help me out?
>> Thanks, Lars
>>

>
>



Reply With Quote
  #4 (permalink)  
Old 07-23-2008, 11:31 PM
Douglas J. Steele
 
Posts: n/a
Re: Finding null

WHERE (MyTable.Straat=[forms]![MyForm].[Street]) AND
(MyTable.HousNr=[forms]![MyForm].[HouseNrAddition] OR
([forms]![MyForm].[HouseNrAddition] IS NULL AND MyTable.HousNr IS NULL)


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Lars Brownie" <lars@brownie.com> wrote in message
news:g68c4n$ct9$1@textnews.wanadoo.nl...
>> Null means "nothing there". Is part of the problem because you are
>> trying to compare to "nothing there"?

>
> Yes. Here is a shortened example:
>
> SELECT MyTable.Member_Name, MyTable.Street, MyTable.HouseNrAddition
> FROM MyTable
> WHERE (((MyTable.Straat)=[forms]![MyForm].[Street]) AND
> ((MyTable.HousNr)=[forms]![MyForm].[HouseNrAddition]));
>
> In a record of MyTable for instance, Street has value MyStreet and
> HouseNrAddition has value Null. If the corresponding form fields have
> similar values, there is no match. I tried several iif's but can't get it
> to work. It does work when HouseNrAddition field on the form is not null.
>
> Thanks, Lars
>
> "Jeff Boyce" <nonsense@nonsense.com> schreef in bericht
> news:O18E1KR7IHA.1196@TK2MSFTNGP05.phx.gbl...
>> Null means "nothing there". Is part of the problem because you are
>> trying to compare to "nothing there"?
>>
>> If you'll post the SQL statement of your query, the folks here would have
>> a few more clues to go on...
>>
>> Regards
>>
>> Jeff Boyce
>> Microsoft Office/Access MVP
>>
>>
>> "Lars Brownie" <lars@brownie.com> wrote in message
>> news:g689fl$c1u$1@textnews.wanadoo.nl...
>>>I have a query with criteria in 2 fields:
>>> FieldA has criteria: [forms]![MyForm].[Field1]
>>> FieldB had criteria: [forms]![MyForm].[Field2]
>>>
>>> So I need an exact match on those 2 fields.
>>>
>>> Field1 is never null but Field2 can be null. If Field2 is null then the
>>> query should look for the Field1 criteria in FieldA AND for a null value
>>> for FieldB. However, this is not working, I get no results. When field2
>>> is not null, it does work.
>>>
>>> Can someone help me out?
>>> Thanks, Lars
>>>

>>
>>

>
>



Reply With Quote
  #5 (permalink)  
Old 07-24-2008, 05:12 AM
Lars Brownie
 
Posts: n/a
Re: Finding null

Though I messed up the query in my last post, you pointed me in the right
direction. Got it working now. Thanks!
Lars

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> schreef in bericht
news:%23LvnKxR7IHA.4108@TK2MSFTNGP04.phx.gbl...
> WHERE (MyTable.Straat=[forms]![MyForm].[Street]) AND
> (MyTable.HousNr=[forms]![MyForm].[HouseNrAddition] OR
> ([forms]![MyForm].[HouseNrAddition] IS NULL AND MyTable.HousNr IS NULL)
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Lars Brownie" <lars@brownie.com> wrote in message
> news:g68c4n$ct9$1@textnews.wanadoo.nl...
>>> Null means "nothing there". Is part of the problem because you are
>>> trying to compare to "nothing there"?

>>
>> Yes. Here is a shortened example:
>>
>> SELECT MyTable.Member_Name, MyTable.Street, MyTable.HouseNrAddition
>> FROM MyTable
>> WHERE (((MyTable.Straat)=[forms]![MyForm].[Street]) AND
>> ((MyTable.HousNr)=[forms]![MyForm].[HouseNrAddition]));
>>
>> In a record of MyTable for instance, Street has value MyStreet and
>> HouseNrAddition has value Null. If the corresponding form fields have
>> similar values, there is no match. I tried several iif's but can't get it
>> to work. It does work when HouseNrAddition field on the form is not null.
>>
>> Thanks, Lars
>>
>> "Jeff Boyce" <nonsense@nonsense.com> schreef in bericht
>> news:O18E1KR7IHA.1196@TK2MSFTNGP05.phx.gbl...
>>> Null means "nothing there". Is part of the problem because you are
>>> trying to compare to "nothing there"?
>>>
>>> If you'll post the SQL statement of your query, the folks here would
>>> have a few more clues to go on...
>>>
>>> Regards
>>>
>>> Jeff Boyce
>>> Microsoft Office/Access MVP
>>>
>>>
>>> "Lars Brownie" <lars@brownie.com> wrote in message
>>> news:g689fl$c1u$1@textnews.wanadoo.nl...
>>>>I have a query with criteria in 2 fields:
>>>> FieldA has criteria: [forms]![MyForm].[Field1]
>>>> FieldB had criteria: [forms]![MyForm].[Field2]
>>>>
>>>> So I need an exact match on those 2 fields.
>>>>
>>>> Field1 is never null but Field2 can be null. If Field2 is null then the
>>>> query should look for the Field1 criteria in FieldA AND for a null
>>>> value for FieldB. However, this is not working, I get no results. When
>>>> field2 is not null, it does work.
>>>>
>>>> Can someone help me out?
>>>> Thanks, Lars
>>>>
>>>
>>>

>>
>>

>
>



Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:27 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109