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

  • Thread starter Thread starter slagg7575
  • Start date Start date
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!
 
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
 
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!
 
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"
 
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,
 
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
 
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
 
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!!!!!
 
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
 
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
 
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.
 
Most of the numbers I am working with have a
fixed ranged of x.xx.

In an earlier post in this thread you said "The values ranges are
always xx.xx, but human error can put the number 1.16(x.xx) as
116(xxx)."

So is x.xx valid or invalid? Does is a trailing zero (e.g. 02.30)
allowed/mandatory for a 1 'decimal place' value...?

I would find it helpful if you could provide a (long) list of valid and
invalid values, so that anyone can test a proposed solution before
posting.

Also, is this data numeric in nature (e.g. are you performing
mathematics on the values) or is it text (e.g. a reference number)? On
one hand, it sounds like the data is fixed with text with a pattern
'[0-9][0-9].[0-9][0-9]'; on the other, it sounds like DECIMAL(4, 2). It
may help if you tell what you are using the data for.

Thanks,
Jamie.

--
 
onedaywhen said:
On
one hand, it sounds like the data is fixed with text with a pattern
'[0-9][0-9].[0-9][0-9]'; on the other, it sounds like DECIMAL(4, 2).

At a guess, still hedging:

CREATE TABLE Test7 (
text_col CHAR(5) NOT NULL,
CONSTRAINT text_col__pattern
CHECK (text_col LIKE '[0-9 ][0-9].[0-9][0-9 ]'),
dec_col DECIMAL(4, 2) NOT NULL,
CONSTRAINT dec_col__values
CHECK (dec_col BETWEEN 0.01 AND 99.99)
);

Jamie.

--
 
Back
Top