Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 IsNull

Author  Topic 

sgw
Starting Member

1 Post

Posted - 2002-02-26 : 16:05:45
Hi all...I'm querying an access DB....(Inner Join below)...and if a record is null then I want to set it to a default value (in this example the variable a (which is a string variable).

I'm getting syntax errors...can you use IsNull in a SQL statement with access?...I can check the values after (before I do anything with it), but I am curious if I can do it in the Select.

Thanks in advance!

a="RunA"
(SELECT IsNull(Run_Name,a) FROM Run rn WHERE rn.Run_ID=r.Run)as Run_Name

izaltsman
A custom title

1139 Posts

Posted - 2002-02-26 : 16:12:06
In Access IsNull simply tests for NULL values and returns TRUE or FALSE. So you'll have to use iif function to actually substitute the value. Something along the lines of:
iif(IsNull(Run_Name), a,Run_Name)


Edited by - izaltsman on 02/26/2002 16:12:19
Go to Top of Page

khenry
Starting Member

16 Posts

Posted - 2002-03-06 : 10:34:46
IIF (inline if) is slow in access due to the fact that it always evaluates both possibilities before returning one.

Access 97+ can use Nz([FieldName],"ValueIfNull")

ie

select Nz([rn].[Run_Name], 'RunA')
FROM Run rn
WHERE rn.Run_ID='whatever'


K e i t h H e n r y
Go to Top of Page
   

- Advertisement -