Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Plz, Need Help 1

Status
Not open for further replies.

HNA

Programmer
Jan 13, 2003
87
KW
Access XP:

How Can I Force The User To Enter In The Text Box:
6 or 12 or 18 or 24 or ..............etc
It's Part Of My Work To Have This Qty Only.

Thanx In Advance


" Åä Çááå íÍÈ ÅÐÇ Úãá ÃÍÏßã ÚãáÇ Ãä íÊÞäå "
 
Sure...

Create an event procedure in the Before Update event of the text box and add code that looks like this:

Code:
Dim intRemainder As Integer
If Not IsNull(Me!txtMyText) Then
    intRemainder = Me!txtMyText Mod 6
    If intRemainder <> 0 Then
        MsgBox &quot;Invalid data.  Value must be a multiple of 6.&quot;
        DoCmd.CancelEvent
        SendKeys &quot;{ESC}&quot;
    End If
End If

... where &quot;txtMyText&quot; is the name of your text box. You'll also want to set the format of your field to a number type and/or set an input mask or otherwise test for non-numeric data in the field so you don't get type mismatch errors.

Ken S.

Ken S.
 
Thanx Eupher
That Was Nice
I Appreciate it

&quot; Åä Çááå íÍÈ ÅÐÇ Úãá ÃÍÏßã ÚãáÇ Ãä íÊÞäå &quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top