How to create popup massage box when data entered is Incorrect?

S

slagg7575

Hi all,
I have several fields that contain lab values, eg. 99.99 that I would
like a popup message to show if a user enters 999.9 by accident. Other
than entering an input mask, how exactly do i do this? Can anyone
actually write out the code I would use, I assume on the afterupdate
event of the field box.

Thanks a million!
 
M

Mr B

In table design mode, try placing the following entry in the Validation Rule
property for the field:

<=99.99

Then place an entry like:
"Entry cannot be larger than 99.99"
in the Validation Text property for the field

This will cause a message to be displayed when some enters any amount
greater than 99.99
 
S

slagg7575

Thanks for the reply...but the number is just a general fixed figure,
the 99.99 are placeholders. The numbers could be 34.5, 2.34, 11.45,
etc. I just want a general way of preventing someone from entering a
wrong number. The values ranges are always xx.xx, but human error can
put the number 1.16(x.xx) as 116(xxx). I need a warning box to popup if
this happens.

Thanks for all your time and help!
 
A

AccessVandal via AccessMonster.com

Try Format.

Me.YourControlName.Format = "00.00"
in current event of the form or afterupdate of your control.

or in the control properties Format tab enter "00.00"
 
S

slagg7575

Thanks,

Will try that, but is there still anyway to get a warning message box
if the user enters it wrong? I would like to try an IIF statement, but
dont know how to do it.

Thanks,
 
A

AccessVandal via AccessMonster.com

Someone might have a function or something

Access will round up if you try to input something like
0.0199999999999999999999999 – you get 0.02.

Try toying around with the code below and you'll see what i mean.

Private Sub Text0_AfterUpdate()
If Me.Text0 > 99.99 Then
Call Text0_Input ‘MsgBox "more than 99.99"
ElseIf Me.Text0 < 0.01 Then
Call Text0_Input ‘MsgBox "less than 0.01"
ElseIf Me.Text0 > 0.01 And Me.Text0 < 0.02 Then
Call Text0_Input ‘MsgBox "between 0.01 to 0.02"
End If
Me.Text0.Format = “00.00”
End Sub

Private Sub Text0_Input()
MsgBox "You have entered a incorrect value of " & """" & _
Me.Text0 & """" & vbCrLf & _
"Please enter the correct value of " & "NN.NN"
Me.Text0 = ""
Me.Text0.SetFocus
Me.Text0.Format = "00.00"
End Sub
 
A

AccessVandal via AccessMonster.com

You might need to add this,

Dim IntCount As Integer

IntCount = Len(Me.Text0)

add another Elseif to,
ElseIf Me.Text0 > 0.01 And Me.Text0 < 0.02 Then
Call Text0_Input ‘MsgBox "between 0.01 to 0.02"
ElseIf IntCount > 5 Then
Call Text0_Input ' more than 5
 
S

slagg7575

Thanks to everyone for their generous help! What I really need is a way
to prevent users from entering the wrong data by accident.
Example. Total Cholesterol- 34.4 NOT 344

They have to enter data in this format x.xx or xx.xx. If they enter
anything other than this (xx.xx or x.xx) I need the warning to fire up
to remind them of the formatting error.
Something like, WARNING WRONG DATA TYPE ENTERED PLEASE CORRECT!
Thanks!!!!!
 
J

jahoobob via AccessMonster.com

Access cannot determine what someone intends to enter. All of the solutions
offered are what Access can do as far as data validation however, if someone
intended to enter 34.4 and entered 344 Access can't determine that they
entered the data incorrectly if 344 is a valid number.
For instance, my LDL is 86.4 but it could be 8.64. There is no way for
Access to say that 8.64 is the wrong entry for my LDL because it could be 8.
64!

Thanks to everyone for their generous help! What I really need is a way
to prevent users from entering the wrong data by accident.
Example. Total Cholesterol- 34.4 NOT 344

They have to enter data in this format x.xx or xx.xx. If they enter
anything other than this (xx.xx or x.xx) I need the warning to fire up
to remind them of the formatting error.
Something like, WARNING WRONG DATA TYPE ENTERED PLEASE CORRECT!
Thanks!!!!!
You might need to add this,
[quoted text clipped - 9 lines]
Call Text0_Input ' more than 5
 
S

slagg7575

Thanks again,

I see what your saying, but if your LDL was entered as 846, by error,
that would not be good!?! Most of the numbers I am working with have a
fixed ranged of x.xx.
The only other option I can think of is an input mask maybe? I would
still like the format warning to popup though. Can it not be done with
an IFF statement?
Thanks!
Access cannot determine what someone intends to enter. All of the solutions
offered are what Access can do as far as data validation however, if someone
intended to enter 34.4 and entered 344 Access can't determine that they
entered the data incorrectly if 344 is a valid number.
For instance, my LDL is 86.4 but it could be 8.64. There is no way for
Access to say that 8.64 is the wrong entry for my LDL because it could be 8.
64!

Thanks to everyone for their generous help! What I really need is a way
to prevent users from entering the wrong data by accident.
Example. Total Cholesterol- 34.4 NOT 344

They have to enter data in this format x.xx or xx.xx. If they enter
anything other than this (xx.xx or x.xx) I need the warning to fire up
to remind them of the formatting error.
Something like, WARNING WRONG DATA TYPE ENTERED PLEASE CORRECT!
Thanks!!!!!
You might need to add this,
[quoted text clipped - 9 lines]
Call Text0_Input ' more than 5
End If
 
A

AccessVandal via AccessMonster.com

Best solution is User discretion.

Just use the Format and Input Mask. Set it to “00.00”.

Since it is impossible to know what is the correct input
even with a function like IIF.

Unless, if the PC with the Application is directly connected to testing
devices or just like a BarCode reader.
With that, the chances of errors are reduced.
 
Top