Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 7th, 2003, 06:43 PM
Authorized User
 
Join Date: Jun 2003
Location: , FL, USA.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cancel a keystroke

I am attempting to cancel a keystroke thru code and am not having any luck. I have a textbox on a form that I want to limit to 30 characters. I have the field in the underlying table set to a max of 30 but I want to warn the user that the maxinum has been exceeded (at 31 characters) and activate the backspace key (KeyAscii(8)). I have included an IF..THEN option in mt textbox_Change event but I am unable to get the backspace function working. Any ideas or suggestions are greatly appreciated.

Thanx in Advance


Kenny Alligood
__________________
Kenny Alligood
Reply With Quote
  #2 (permalink)  
Old June 9th, 2003, 12:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try putting some code in the textbox's Key Up event.

Something along the lines of this should work:
Code:
Private Sub Text0_KeyUp(KeyCode As Integer, Shift As Integer)
If Len(Text0.Text) > 30 Then SendKeys Chr(8)
End Sub

HTH

Steven

I am a loud man with a very large hat. This means I am in charge.
Reply With Quote
  #3 (permalink)  
Old June 9th, 2003, 11:37 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by Kenny Alligood
 I am attempting to cancel a keystroke thru code and am not having any luck. I have a textbox on a form that I want to limit to 30 characters. I have the field in the underlying table set to a max of 30 but I want to warn the user that the maxinum has been exceeded (at 31 characters) and activate the backspace key (KeyAscii(8)).
 I don't understand why you need to code this. If the field is limited to 30 characters then when the user tries to type the 31st character, Access will just not type it. The user then knows that the limit has been reached. Because the 31st character will not be even allowed to be typed, there is no need to activate a backspace. Doing so will erase the 30th character. You don't want that.

Unless I misunderstand your intention it sounds like you're creating more work for yourself. Let Access function by default in this case.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #4 (permalink)  
Old June 12th, 2003, 09:57 AM
Authorized User
 
Join Date: Jun 2003
Location: , FL, USA.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your reply worked the charm I needed - thanx for the advice.

Kenny Alligood
Reply With Quote
  #5 (permalink)  
Old June 12th, 2003, 10:02 AM
Authorized User
 
Join Date: Jun 2003
Location: , FL, USA.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by SerranoG
 
Quote:
quote:Originally posted by Kenny Alligood
Quote:
 I am attempting to cancel a keystroke thru code and am not having any luck. I have a textbox on a form that I want to limit to 30 characters. I have the field in the underlying table set to a max of 30 but I want to warn the user that the maxinum has been exceeded (at 31 characters) and activate the backspace key (KeyAscii(8)).
 I don't understand why you need to code this. If the field is limited to 30 characters then when the user tries to type the 31st character, Access will just not type it. The user then knows that the limit has been reached. Because the 31st character will not be even allowed to be typed, there is no need to activate a backspace. Doing so will erase the 30th character. You don't want that.

Unless I misunderstand your intention it sounds like you're creating more work for yourself. Let Access function by default in this case.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
The reason that I wanted to include code was that Access does indeed limit the fields maximum property but it does not let the user know that it is limited. I tested that to be certain but that is the case. When I entered more than 30 characters the textbox processed the text up to the 30th character and removed the rest - never letting the user know this. If the user has no way to see the underlying table (which mine do not) then they would never know that a portion of their data was deleted due to size limitations. With the code I can include a MsgBox and backspace key to alert the user accordingly. Nevertheless, I do appreciate your reply it gave me the opportunity to test something that I wasn't certain about to begin with. As such, I have always wanted to include code to control my environment as opposed to depending on the application.

Kenny Alligood
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cancel appointment jeanhl BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 March 25th, 2008 03:55 AM
How can I cancel deleting ? ALGNET ADO.NET 1 March 22nd, 2006 01:55 PM
how about cancel a process kevsboy Beginning VB 6 0 February 12th, 2006 11:03 PM
Capture Keystroke in a text box xgbnow Visual C++ 0 October 1st, 2003 11:34 AM



All times are GMT -4. The time now is 02:06 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.