I need a message to pop up

D

Dimitris

Hello,

There is a text field in a form in which numbers are entered. If the user
enters over 8 digits I want a message to pop up saying "OVER 8 DIGITS" if
the user enters under 8 digits i want a message to pop up saying "UNDER 8
DIGITS". I don't want anything else to happen. The user will click OK and
continue.

Can someone help me?
Thank you
Dimitris
 
P

Philip Herlihy

Dimitris said:
Hello,

There is a text field in a form in which numbers are entered. If the user
enters over 8 digits I want a message to pop up saying "OVER 8 DIGITS" if
the user enters under 8 digits i want a message to pop up saying "UNDER 8
DIGITS". I don't want anything else to happen. The user will click OK and
continue.

Can someone help me?
Thank you
Dimitris

There's something which should suit you already built-in to Access.
Search help for "validation rule" - essentially you provide a condition
which must be met and a message to be displayed if it isn't.

Phil, London
 
D

Dimitris

I'm sorry but I am new in Access.
How do I write over or under 8 digits?
I can't seem to figure that out.
 
K

Klatuu

Use the Before Update event of the control where you enter the digigts:

Private Sub txtDigits_BeforeUpdate(Cancel As Integer)
Dim strOverUnder As String

If Len(Me.txtDigits) > 8 Then
strOverUnder = "Over 8 Digits"
ElseIf Len(Me.txtDigits) < 8 Then
strOverUnder = "Under 8 Digits"
Else
strOverUnder = vbNullString
End If

If strOverUnder <> vbNullString Then
MsgBox strOverUnder
End If
End Sub
 
D

Dimitris

Thank you for your help.
That worked fine

Klatuu said:
Use the Before Update event of the control where you enter the digigts:

Private Sub txtDigits_BeforeUpdate(Cancel As Integer)
Dim strOverUnder As String

If Len(Me.txtDigits) > 8 Then
strOverUnder = "Over 8 Digits"
ElseIf Len(Me.txtDigits) < 8 Then
strOverUnder = "Under 8 Digits"
Else
strOverUnder = vbNullString
End If

If strOverUnder <> vbNullString Then
MsgBox strOverUnder
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top