Solved

How replace empty number field with a "0.00"

Posted on 2013-06-14
8
340 Views
Last Modified: 2013-06-14
On a form field I have a number field.  It the user clears the value in the field I want to replace it with a 0.00.

I've tried this but it doesn't work: (the field name is "1000"

=IIf([1000]="",0,[1000])
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 11

Expert Comment

by:Guru Ji
ID: 39247558
you can try this

IIf(Nz(1000.value) = vbNullString,0,[1000])
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 39247561
If this is a numeric field...it will not = "".
iif(isnull([1000]),0,[1000])

scott c
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 39247567
Plus... you can forma a 0 to look like 0.00  ... but 0.00 is not a legitimate number.
1.0 = 1
1.1 = 1.1

0.00 = 0

etc.

scott C
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:SteveL13
ID: 39247593
IIf(Nz(1000.value) = vbNullString,0,[1000])  did not work.
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 39247620
This should do for the value in _another_ field than [1000]:

=Nz([1000],0)

/gustav
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 39247634
If you only have this field, use this in the AfterUpdate event:

  If IsNull(Me![1000].Value) Then
    Me![1000].Value = 0
  End If

/gustav
0
 

Author Comment

by:SteveL13
ID: 39247677
=Nz([1000],0)  did not work.

  If IsNull(Me![1000].Value) Then
    Me![1000].Value = 0
  End If

did work but I have 45 fields to code.
0
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 39247793
Auch. You can use WithEvents to extend the form class module, but that's a learning experience.

Another option is to create a helper subfunction:

Public Sub UpdateNullToZero(ByRef ctl As Control)
  If IsNull(ctl.Value) Then
    ctl.Value = 0
  End If
End Sub

Now, in the AfterUpdate events you just need to paste:

  Call UpdateNullToZero(Me.ActiveControl)

/gustav
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question