Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / May 2007

Tip: Looking for answers? Try searching our database.

iif statements

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pigsy101 - 31 May 2007 17:02 GMT
I'm trying to create a calculated field on a form that tracks stock
levels.

i have three subforms - frmOpeningStock, frmOrdered and frmAllocated.

i'm using the following statement which works fine when all fields are
populated and works when neither the Total Ordered or the Total
Allocated fields are populated.

=IIf(IsNull([frmOrdered].[Form]![Total Ordered]) And
IsNull([tblAllocated].[Form]![Total Allocated]),[frmOpeningStock].
[Form]![number],[frmOpeningStock].[Form]![number]+[frmOrdered].[Form]!
[Total Ordered]-[tblAllocated].[Form]![Total Allocated])

How can i get this to work when either the Total Ordered or the Total
Allocated could be null??

Thanks in advance

P
Al Campagna - 31 May 2007 17:13 GMT
pigsy
  Try the NZ function... see Help.

> =IIf(IsNull([frmOrdered].[Form]![Total Ordered]) And
> IsNull([tblAllocated].[Form]![Total Allocated]),[frmOpeningStock].
> [Form]![number],[frmOpeningStock].[Form]![number]+NZ([frmOrdered].[Form]!
> [Total Ordered])-NZ([tblAllocated].[Form]![Total Allocated]))

Signature

hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."

> I'm trying to create a calculated field on a form that tracks stock
> levels.
[quoted text clipped - 16 lines]
>
> P
Ken Sheridan - 31 May 2007 17:35 GMT
I don't think you need to call the IIf function at all, do you?  A simple
expression returning zeros where the controls are Null should give the same
result:

=[frmOpeningStock].[Form]![number]+Nz([frmOrdered].[Form]![Total
Ordered],0)-Nz([tblAllocated].[Form]![Total Allocated],0)

Ken Sheridan
Stafford, England

> I'm trying to create a calculated field on a form that tracks stock
> levels.
[quoted text clipped - 16 lines]
>
> P
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.