By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,960 Members | 1,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,960 IT Pros & Developers. It's quick & easy.

iif statement in a default value not working

100+
P: 115
Hi I'm working on the invoice customer form
and i had those text box :
txtarticle, txtPrice, txtAfterDiscPrice, txtCashMoney
i want to write this code
Expand|Select|Wrap|Line Numbers
  1. If (txtAfterDiscPrice is null) then txtCashMoney=txtPrice ;
  2. else 
  3. txtCashMoney=txtAfterDiscPrice;
  4. on the default value of the txtCashMoney.
  5.  
so i wrote this on the default value of the txtCashMoney:
Expand|Select|Wrap|Line Numbers
  1. = iif(isnull(txtAfterDiscPrice ) ,= [txtPrice] ,= [txtAfterDiscPrice ] 
but it's not working does anyone know why ?
Aug 5 '10 #1
Share this Question
Share on Google+
7 Replies


NeoPa
Expert Mod 15k+
P: 31,769
If the names and references are right then you could try :
Expand|Select|Wrap|Line Numbers
  1. =Nz([txtAfterDiscPrice],[txtPrice])
Aug 5 '10 #2

100+
P: 255
The problem I see in this line of code would be the formating. In true / false criteria you don't need the "=", try that again with the "=" removed:

Expand|Select|Wrap|Line Numbers
  1. [txtCashMoney]= iif(isnull([txtAfterDiscPrice] ,[txtPrice] ,[txtAfterDiscPrice]) 
Aug 6 '10 #3

Jerry Maiapu
100+
P: 259
Colintis,
Closing brackets is missing and a few corrections.. Though this is a replica of Post#2. For correction sake..

Expand|Select|Wrap|Line Numbers
  1. = IIf(IsNull([txtAfterDiscPrice]) ,[txtPrice] ,[txtAfterDiscPrice])
Aug 6 '10 #4

100+
P: 255
Oops...Thanks for that one Jerry :P
Aug 6 '10 #5

100+
P: 115
Well i tried this one it wont give me errors but nothing happened the field CashMoney still empty :(
maybe i should do this with an event like jim told me
Aug 6 '10 #6

Jerry Maiapu
100+
P: 259
Take note that if txtPrice or txtAfterDiscPrice have null/no values then you might see empty space in CashMoney field. Apart from this I am sure that NZ and IIf..IsNull functions of the previous posts should work perfectly.

Just like you proposed .
Try this on the On_Current event of the form.

Expand|Select|Wrap|Line Numbers
  1. If IsNull(txtAfterDiscPrice) then
  2. me.txtCashMoney=txtPrice  
  3. else  
  4. me.txtCashMoney=txtAfterDiscPrice
  5. end if
Aug 8 '10 #7

NeoPa
Expert Mod 15k+
P: 31,769
You say you've "tried this one", but there are three suggestions you could be referring to. I have no idea what you have and haven't tried so I am not in a position to help at this time.
Aug 9 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.