473,503 Members | 4,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

iif statement dealing with nulls

using access 2000. Have a form based on a couple of controls, it
finds the last used Inquiry number in a table. So it finds the
highest Inquiry number for the "Office" , "Company" and "YearStamp"
selected by the user.

Code below:

=IIf(IsNull(DMax("[Inquiry Number]","Inquiry","[Office] = '" &
[Form]![Office Code] & "' and" & "[Company] = '" & [Form]![Company
Code] & "' and " & "[YearStamp] = " &
[Form]![Year])),0,DMax("[Inquiry Number]","Inquiry","[Office] = '" &
[Form]![Office Code] & "' and" & "[Company] = '" & [Form]![Company
Code] & "' and " & "[YearStamp] = " & [Form]![Year]))

I use to just use the DMax but had to change it to an IIF because of
nulls. But this code simply places #ERROR in the control when it is
null.

Am I doing something wrong? Wait obviously I am doing something
wrong. Can someone lead me in the right direction.

I'm doing this iif statement in the control source property.
Nov 13 '05 #1
2 2521
just off the cuff, have you tried using NZ(dmax etc.) instead of the iif
rdshultz <rd******@nooter.com> posted in
news:87**************************@posting.google.c om
using access 2000. Have a form based on a couple of controls, it
finds the last used Inquiry number in a table. So it finds the
highest Inquiry number for the "Office" , "Company" and "YearStamp"
selected by the user.

Code below:

=IIf(IsNull(DMax("[Inquiry Number]","Inquiry","[Office] = '" &
[Form]![Office Code] & "' and" & "[Company] = '" & [Form]![Company
Code] & "' and " & "[YearStamp] = " &
[Form]![Year])),0,DMax("[Inquiry Number]","Inquiry","[Office] = '" &
[Form]![Office Code] & "' and" & "[Company] = '" & [Form]![Company
Code] & "' and " & "[YearStamp] = " & [Form]![Year]))

I use to just use the DMax but had to change it to an IIF because of
nulls. But this code simply places #ERROR in the control when it is
null.

Am I doing something wrong? Wait obviously I am doing something
wrong. Can someone lead me in the right direction.

I'm doing this iif statement in the control source property.


--
Phil
Nov 13 '05 #2
how about using NZ(<<expression>>) which will convert the Null value
to zero for you?
Nov 13 '05 #3

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

Similar topics

20
4023
by: Max Sandman | last post by:
I'm getting increasingly frustrated with C# and its exceptions on null values. Rather than try to deal with it on a hit-or-miss basis as exceptions pop up, I thought I should try to learn exactly...
9
2349
by: Michael | last post by:
Hi all, I would like to get people's opinion about executing SQL statements in C# (or any other .NET language really). I used to create my SQL statement by building a string and replacing single...
8
1830
by: Brian Basquille | last post by:
Hello all, Bit of a change of pace now. As opposed to the typical questions regarding my Air Hockey game, am also working on a Photo Album which uses an Access Database to store information...
1
1278
by: Angela | last post by:
Hi I am building a very simple data entry system with many forms and input textboxes. When I leave any part of the form empty (it allows nulls) it seems to touch the field in the DB and the...
2
2632
by: Robert Dufour | last post by:
I have a sub to update a record in a sql server 2000 table. There's a field FK, which is defined to allow nulls in the table definition, the field type is integer. How do I write the sub's...
1
1587
by: rdemyan via AccessMonster.com | last post by:
I have the following SQL statement in code: strSQL = "SELECT * FROM TABLEA WHERE F2 = 'SITE' This returns the record that I expect. However: the following does not strSQL = "SELECT *...
2
1677
by: Jimmy | last post by:
If the user dbl clicks the field "vendor" I want it to open frmContacts to a blank record if there is nothing in the current field and if there is, open frm Contacts to that record. I have the...
5
2352
by: BXB | last post by:
I have a number in a table that starts off as currency. There are nulls in the data so I'm trying to convert the nulls to zeros and then wind up back in currency, or in fact in any numeric format. ...
3
3111
by: xlar54 | last post by:
I am writing a parametrized query, where Im building an UPDATE statement through concatenation, and then adding the parameters such as: UPDATE myTable SET = @newcolumna, = @newcolumnb WHERE ...
0
7207
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
7093
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...
1
7012
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5598
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,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.