473,324 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

iif statement in a default value not working

115 100+
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
7 4041
NeoPa
32,556 Expert Mod 16PB
If the names and references are right then you could try :
Expand|Select|Wrap|Line Numbers
  1. =Nz([txtAfterDiscPrice],[txtPrice])
Aug 5 '10 #2
colintis
255 100+
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
259 100+
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
colintis
255 100+
Oops...Thanks for that one Jerry :P
Aug 6 '10 #5
hannoudw
115 100+
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
259 100+
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
32,556 Expert Mod 16PB
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

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

Similar topics

14
by: ago | last post by:
Is it possible to have a default value associated python objects? I.e. to flag an attribute in such a way that the assignment operator for the object returns the default attribute instead of the...
3
by: Ian D | last post by:
Firstly apologies for the convoluted question. I found this problem whilst building a larger database. I've distilled it down to as small as possible and can send a 200k example to anyone who has...
7
by: Justin | last post by:
Is there any way to prevent VB.net to give default value to a variable (changing settings what not...)? For example Dim test As Integer test = test + 1 the statement "test = test + 1"...
2
by: Bob | last post by:
I have a CreatedOn field , datetime, which has GetDate() as the default value in SQL server 2000 table. When I create a new record in the table itself in enterprise manager, the field gets...
10
by: Brad Baker | last post by:
I have an asp.net/csharp application that requires a particular variable to work properly. This variable is usually passed via a query string in the URL when the application is first run but under...
1
by: EJO | last post by:
I've looked around the groups and don't have tried some of the various suggestions to no avail. So I'm hoping someone can help me out here. I have a form that, when a cmd button is clicked,...
4
by: Macneed | last post by:
i am a newbie, i remember i read a book talking about when u declare a array variable using float ABC = new float; the whole array element in ABC ( ABC to ABC ) will automatic initialize to 0...
43
by: kenneth | last post by:
Dear all, I have encountered this weird problem. I have a class definition with an __init__ argument 'd' which defaults to {}. This argument is put in the 'self.d' attribute at initialization...
9
by: lawpoop | last post by:
I'm trying to write some simple code, but I might be simplifying it too much. I have a function that either returns a string that I want, or FALSE. In the code that I'm working on, I would like...
2
topher23
by: topher23 | last post by:
Disclaimer: I've already come up with a solution for this issue, but I thought I'd post it in the hope that it could help someone else and on the off chance that someone has another solution. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.