Chris Mackin
chris at denverdb.com
Fri Feb 14 14:04:00 CST 2003
You can use the Change event and something like: If me!txtMine.Text > 999 Then msgbox "Error Message Here - Invalid Entry" '....whatever you want to do with that entry goes here end if You'd have to check for IsNumeric and IsNull and handle those as well I'd imagine, but this should get you started at least. Chris Mackin www.denverdb.com Denver Database Consulting, LLC -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com]On Behalf Of Joe Rojas Sent: Friday, February 14, 2003 12:51 PM To: 'accessd at databaseadvisors.com' Subject: RE: [AccessD] Only allow 3 digits in a textbox Hey Chris, The more that I look at the simple version, using the input mask, the more I realize that it is its shortcomings. For example, if the user clicks on the textbox in order to set focus, the insertion of the cursor is where ever the user clicked and not at the beginning of the textbox. Joe Rojas -----Original Message----- From: Christopher Hawkins [mailto:CHawkins at aimworld.com] Sent: Friday, February 14, 2003 2:32 PM To: 'accessd at databaseadvisors.com' Subject: RE: [AccessD] Only allow 3 digits in a textbox Bob, Remember the programmer's credo - the more complicated a solution, the more fun it is to code! ;) Joe, Bob's idea is a good one. But if you want to get the user more involved in the proces, you could add code in the OnExit or AfterUpdate that uses Len() to evaluate the length of the string and pops up a message box prompting the user to enter appropriate data if more than 3 characters are found. If you want to be really strict, you can use SetFocus to keep the user from tabbing out of that control until the 3-digit condition is satisfied. -Christopher- -----Original Message----- From: Bob Gajewski [mailto:bob at renaissancesiding.com] Sent: Friday, February 14, 2003 11:25 AM To: 'accessd at databaseadvisors.com' Subject: RE: [AccessD] Only allow 3 digits in a textbox Joe Maybe this is an overly-simplistic approach, but why don't you just specify an Input Mask (000;;_) or (990;;_) ? Bob Gajewski On Friday, February 14, 2003 13:41 PM, Joe Rojas [SMTP:JRojas at tnco-inc.com] wrote: > Hi All, > > A2K - unbound form > > I am trying to create a textbox that only allows whole numbers AND only > allows three digits > > I am working with the KeyPress event of this textbox > > What I have so far only allows digits to be entered, but I can't determine > the length of the textbox. If I use Me.textbox or Me.txtbox.Text or > Me.txtbox.Value it returns Null regardless of the actual contents of the > textbox > > Here is what I have so far: > > > Private Sub txtNumOfOccurr_KeyPress(KeyAscii As Integer) > > If (IsNull(Me.txtNumOfOccurr)) Or (Not (Len(Me.txtNumOfOccurr) = 3)) Then > If Not (IsNumeric(Chr(KeyAscii))) And (KeyAscii <> 8) Then > KeyAscii = 0 > End If > Else > KeyAscii = 0 > End If > > End Sub > > Any ideas? > > Thanks, > > Joe Rojas > jrojas at tnco-inc.com > > > > > This electronic transmission is strictly confidential to TNCO, Inc. and > intended solely for the addressee. It may contain information which is > covered by legal, professional, or other privileges. If you are not the > intended addressee, or someone authorized by the intended addressee to > receive transmissions on behalf of the addressee, you must not retain, > disclose in any form, copy, or take any action in reliance on this > transmission. If you have received this transmission in error, please notify > the sender as soon as possible and destroy this message. While TNCO, Inc > uses virus protection, the recipient should check this email and any > attachments for the presence of viruses. TNCO, Inc. accepts no liability for > any damage caused by any virus transmitted by this email > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > > _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com This electronic transmission is strictly confidential to TNCO, Inc. and intended solely for the addressee. It may contain information which is covered by legal, professional, or other privileges. If you are not the intended addressee, or someone authorized by the intended addressee to receive transmissions on behalf of the addressee, you must not retain, disclose in any form, copy, or take any action in reliance on this transmission. If you have received this transmission in error, please notify the sender as soon as possible and destroy this message. While TNCO, Inc. uses virus protection, the recipient should check this email and any attachments for the presence of viruses. TNCO, Inc. accepts no liability for any damage caused by any virus transmitted by this email. _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com