Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 07-23-2009, 02:10 AM   #1
swaroop1012
Registered User
 
Join Date: Nov 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
swaroop1012 is on a distinguished road
How to make textbox accept only P,R,I,D,E characters?

Hi all,

I have a database where there is a text box in which the user has to enter only P,R,I,D,E characters. Is it possible to do that.

Thanks in advance.

swaroop1012 is offline   Reply With Quote
Old 07-23-2009, 02:16 AM   #2
John Big Booty
AWF VIP
 
John Big Booty's Avatar
 
Join Date: Aug 2005
Location: Planet 10, by way of the Eighth Dimension
Posts: 8,263
Thanks: 113
Thanked 1,023 Times in 873 Posts
John Big Booty is a jewel in the rough John Big Booty is a jewel in the rough John Big Booty is a jewel in the rough
Re: How to make textbox accept only P,R,I,D,E characters?

Do you want the text box to only accept a single character from your list, or any combination of characters from your list?
__________________
...but they're only monkey boys!!!
John Big Booty is offline   Reply With Quote
Old 07-23-2009, 02:56 AM   #3
DCrake
Remembered
 
DCrake's Avatar
 
Join Date: Jun 2005
Location: Burnley, Lancashire
Posts: 8,634
Thanks: 8
Thanked 328 Times in 209 Posts
DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light
Send a message via Skype™ to DCrake
Re: How to make textbox accept only P,R,I,D,E characters?

If the user can only select on the characters then why not use a combo box instead?

__________________
David Crake


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
The Home of Simple Software Solutions.

O/S Windows XP (SP3) & Windows 7 64bit
Access 2003 (version 11.0)
Access 2007 (version 12.0)

Remember when posting sample databases you will get a better response if it is pre Access 2007 - not all people have it installed.
DCrake is offline   Reply With Quote
Old 07-23-2009, 05:00 AM   #4
swaroop1012
Registered User
 
Join Date: Nov 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
swaroop1012 is on a distinguished road
Re: How to make textbox accept only P,R,I,D,E characters?

Quote:
Originally Posted by John Big Booty View Post
Do you want the text box to only accept a single character from your list, or any combination of characters from your list?

Hi John,

The user has to select combination of those letters.

Thanks
swaroop1012 is offline   Reply With Quote
Old 07-23-2009, 05:01 AM   #5
swaroop1012
Registered User
 
Join Date: Nov 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
swaroop1012 is on a distinguished road
Re: How to make textbox accept only P,R,I,D,E characters?

Quote:
Originally Posted by DCrake View Post
If the user can only select on the characters then why not use a combo box instead?

Hi Crake,

the user has to select multiple valuse which is not possible with combo box.

Cheers.
swaroop1012 is offline   Reply With Quote
Old 07-23-2009, 05:05 AM   #6
Kryst51
Singin' in the Hou. Rain
 
Kryst51's Avatar
 
Join Date: Jun 2009
Location: Texas
Posts: 1,898
Thanks: 0
Thanked 1 Time in 1 Post
Kryst51 will become famous soon enough Kryst51 will become famous soon enough
Re: How to make textbox accept only P,R,I,D,E characters?

Quote:
Hi Crake,

the user has to select multiple valuse which is not possible with combo box.

Cheers.
What about multiple combo boxes?
Kryst51 is offline   Reply With Quote
Old 07-23-2009, 05:05 AM   #7
DCrake
Remembered
 
DCrake's Avatar
 
Join Date: Jun 2005
Location: Burnley, Lancashire
Posts: 8,634
Thanks: 8
Thanked 328 Times in 209 Posts
DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light
Send a message via Skype™ to DCrake
Re: How to make textbox accept only P,R,I,D,E characters?

Use a BeforeUpdate/AfterUpdate validation check on the user input or use the KeyPress event to examine the keycode pressed.

__________________
David Crake


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
The Home of Simple Software Solutions.

O/S Windows XP (SP3) & Windows 7 64bit
Access 2003 (version 11.0)
Access 2007 (version 12.0)

Remember when posting sample databases you will get a better response if it is pre Access 2007 - not all people have it installed.
DCrake is offline   Reply With Quote
Old 07-23-2009, 05:07 AM   #8
swaroop1012
Registered User
 
Join Date: Nov 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
swaroop1012 is on a distinguished road
Re: How to make textbox accept only P,R,I,D,E characters?

Quote:
Originally Posted by Kryst51 View Post
What about multiple combo boxes?
i dont think it is possible..even it is possible, it makes the form look bad and i think its not a good procedure.
swaroop1012 is offline   Reply With Quote
Old 07-23-2009, 05:10 AM   #9
gemma-the-husky
Super Moderator
 
gemma-the-husky's Avatar
 
Join Date: Sep 2006
Location: UK
Posts: 13,843
Thanks: 56
Thanked 1,046 Times in 1,008 Posts
gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all
Re: How to make textbox accept only P,R,I,D,E characters?

with such a small selection, you could have a multi-select LIST BOX.

alternatively you could just have some buttons/check boxes, one for each letter
__________________
Dave (Male!)
Gemma was my dog

if a poster helps you, please click the scales at the bottom left of this posting, or use the thanks button alongside.

Last edited by gemma-the-husky; 07-23-2009 at 05:19 AM.
gemma-the-husky is offline   Reply With Quote
Old 07-23-2009, 05:10 AM   #10
Kryst51
Singin' in the Hou. Rain
 
Kryst51's Avatar
 
Join Date: Jun 2009
Location: Texas
Posts: 1,898
Thanks: 0
Thanked 1 Time in 1 Post
Kryst51 will become famous soon enough Kryst51 will become famous soon enough
Re: How to make textbox accept only P,R,I,D,E characters?

Quote:
i dont think it is possible..even it is possible, it makes the form look bad and i think its not a good procedure.
I think my thought was that if you had a table that had fields, each field contains one character. And another table that included each option, then link that table to the fields in the other table through combo boxes on a form, then users could select their combination quite easily, Also, I bet you could do some kind of coding that made the cursor jump to the next combo box after a letter was entered, like a lot of websites that require you to enter phone numbers or social security numbers that have a fixed number of digits.
Kryst51 is offline   Reply With Quote
Old 07-23-2009, 05:13 AM   #11
swaroop1012
Registered User
 
Join Date: Nov 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
swaroop1012 is on a distinguished road
Re: How to make textbox accept only P,R,I,D,E characters?

Quote:
Originally Posted by Kryst51 View Post
I think my thought was that if you had a table that had fields, each field contains one character. And another table that included each option, then link that table to the fields in the other table through combo boxes on a form, then users could select their combination quite easily, Also, I bet you could do some kind of coding that made the cursor jump to the next combo box after a letter was entered, like a lot of websites that require you to enter phone numbers or social security numbers that have a fixed number of digits.
Hi Kryst,

The problem is i almost finished with the database and now just trying to tweak it for better user satisfaction. if u want i will send u the database to have a look at.

Cheers.
swaroop1012 is offline   Reply With Quote
Old 07-23-2009, 05:15 AM   #12
Kryst51
Singin' in the Hou. Rain
 
Kryst51's Avatar
 
Join Date: Jun 2009
Location: Texas
Posts: 1,898
Thanks: 0
Thanked 1 Time in 1 Post
Kryst51 will become famous soon enough Kryst51 will become famous soon enough
Re: How to make textbox accept only P,R,I,D,E characters?

Quote:
The problem is i almost finished with the database and now just trying to tweak it for better user satisfaction. if u want i will send u the database to have a look at.
Oh, OK, No Problem. I don't know a lot of complex ways to do things, so I try to think of simplified ways. I would be happy to look at the database.
Kryst51 is offline   Reply With Quote
Old 07-23-2009, 05:17 AM   #13
swaroop1012
Registered User
 
Join Date: Nov 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
swaroop1012 is on a distinguished road
Re: How to make textbox accept only P,R,I,D,E characters?

Quote:
Originally Posted by Kryst51 View Post
Oh, OK, No Problem. I don't know a lot of complex ways to do things, so I try to think of simplified ways. I would be happy to look at the database.
Hi Kryst,

here is the copy of database as an attachment

Cheers.
Attached Files
File Type: zip db1.zip (185.7 KB, 83 views)
swaroop1012 is offline   Reply With Quote
Old 07-23-2009, 05:33 AM   #14
missinglinq
AWF VIP
 
missinglinq's Avatar
 
Join Date: Jun 2003
Location: Richmond (Virginia that is!)
Posts: 6,323
Thanks: 11
Thanked 725 Times in 674 Posts
missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light
Re: How to make textbox accept only P,R,I,D,E characters?

This will allow the letters listed to be entered and allow the user to move within the textbox using the arrow keys, delete key, etc:

Code:
Private Sub YourTextBox_KeyDown(KeyCode As Integer, Shift As Integer)
 Select Case KeyCode
  Case vbKeyP, vbKeyR, vbKeyI, vbKeyD, vbKeyE, vbKeyLeft, vbKeyRight, vbKeyReturn, vbKeyDelete, vbKeyBack, vbKeySpace
   KeyCode = KeyCode
  Case Else
   KeyCode = 0
  End Select
End Sub
__________________
The Devil's in the Details!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


(All code solutions tested in Access 2003/2007, before posting, unless otherwise noted.)
missinglinq is offline   Reply With Quote
Old 07-23-2009, 05:42 AM   #15
Kryst51
Singin' in the Hou. Rain
 
Kryst51's Avatar
 
Join Date: Jun 2009
Location: Texas
Posts: 1,898
Thanks: 0
Thanked 1 Time in 1 Post
Kryst51 will become famous soon enough Kryst51 will become famous soon enough
Re: How to make textbox accept only P,R,I,D,E characters?

I tried missinglinq's code in your db, it works perfectly to just allow the letters! Awesome! Much better than how I was thinking.

Kryst51 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Dynamically updating characters typed kroeg Forms 2 05-12-2005 07:00 AM
Count characters in textbox??? (text not selected) Steff_DK Modules & VBA 2 02-13-2005 05:01 PM
Make asterisk appear in textbox when hitting enter? Jenny Peters General 2 01-07-2003 08:25 PM
How to make a textbox grow horizontally? azzurri Reports 3 09-27-2002 09:16 AM
DO While Loop Dina01 Modules & VBA 1 05-29-2002 07:34 AM




All times are GMT -8. The time now is 10:29 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World