show warning when a calculated total<0

  • Thread starter Thread starter Goldar
  • Start date Start date
G

Goldar

How can I detect the condition that occurs when a calculated field becones
negative? I would like to issue a warning message at that time.

Thanks,
 
Goldar,
That's enough information to give a specific solution...
Are you talking about a form, or a query, or a report?
What's the calculation?
Describe the value/s that constitute the calculation.
Please... more info...

Essentially though... what event/s would effect/change that calculation
value?
Use those events to trigger an evaluation of the new value, and respond
accordingly.
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Goldar said:
How can I detect the condition that occurs when a calculated field becones
negative? I would like to issue a warning message at that time.


You would have to do the calculation using VBA code in an
event procedure instead of a text box expression.

OTOH, you could scrap the warning message idea and change
the textbox's ForeColor by using a custom format for the
text box. E.g.
0.00;[RED]-0.00
 
It's a summation on a very simple form. The form contains up to 5 lines of
data where each line contains: [un[Amount approved], [Amount spent], and a
line total =nz([Amount approved],0) - nz([Amount spent],0)). On the sixth
line are column totals and a total of all the line totals is
=nz([LineTotal1],0)+nz([LineTotal2],0)+nz([LineTotal3],0)+nz([LineTotal4],0)+nz([LineTotal5],0).
What I would like to have happen would be that when the final total (line 6)
is calculated to be negative, I could issue a warning to the operator.
Generally, this condition indicated an input error.

Thanks,
 
Goldar,
If a user message is necessary, there are many ways to handle that.
(ex. a Sub or a Function, etc...)

You can use the AfterUpdate event of LT1 through LT5 to check the
calculated value and post a message accordingly.
(you didn't indicate the name if the control that adds up all 5 LineTotals,
so
I'll use [GTotal])

Private Sub LineTotal1_AfterUpdate()
If GTotal <= 0 Then
Beep
MsgBox "GTotal is less than 0", vbOKOnly
End if
End Sub

-OR------------

Private Function CheckTotals()
If GTotal <= 0 Then
Beep
MsgBox "GTotal is less than 0", vbOKOnly
End if
End Function
Then place...
=CheckTotals()
in the AfterUpdate property textbox of each LineTotal1 through LineTotal5
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

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


Goldar said:
It's a summation on a very simple form. The form contains up to 5 lines of
data where each line contains: [un[Amount approved], [Amount spent], and a
line total =nz([Amount approved],0) - nz([Amount spent],0)). On the sixth
line are column totals and a total of all the line totals is
=nz([LineTotal1],0)+nz([LineTotal2],0)+nz([LineTotal3],0)+nz([LineTotal4],0)+nz([LineTotal5],0).
What I would like to have happen would be that when the final total (line
6)
is calculated to be negative, I could issue a warning to the operator.
Generally, this condition indicated an input error.

Thanks,


Al Campagna said:
Goldar,
That's enough information to give a specific solution...
Are you talking about a form, or a query, or a report?
What's the calculation?
Describe the value/s that constitute the calculation.
Please... more info...

Essentially though... what event/s would effect/change that
calculation
value?
Use those events to trigger an evaluation of the new value, and
respond
accordingly.
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

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





.
 
Back
Top