473,394 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Prevent characters

Sal
How can I prevent same characters from being enter in field on a form.
For example "#$%@"
Please Help
Thanks
Slawek
Nov 12 '05 #1
4 2587
Set the form's KeyPreview property to Yes.
In the Keypress event of the form:

Select Case KeyAscii
Case 35, 36, 37, 64
KeyAscii = 0
End Select

Use Asc() to figure out the ASCII value.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Sal" <sl*****@bellatlantic.net> wrote in message
news:ay*******************@nwrdny02.gnilink.net...
How can I prevent same characters from being enter in field on a form.
For example "#$%@"
Please Help
Thanks
Slawek

Nov 12 '05 #2
"Sal" <sl*****@bellatlantic.net> wrote in message news:<ay*******************@nwrdny02.gnilink.net>. ..
How can I prevent same characters from being enter in field on a form.
For example "#$%@"
Please Help
Thanks
Slawek

I have used a function to remove the characters on the after update
event of the field
Public Function RemoveChars(strString As String) As String
On Error GoTo RemoveChars_Err

Dim strResult As String
Dim iCtr As Integer

For iCtr = 1 To Len(strString)
Select Case UCase(Mid(strString, iCtr, 1))
Case "#","$","%","@"
'do not add character
Case Else
strResult = strResult & Mid(strString, iCtr, 1)
End Select
Next iCtr

RemoveChars = strResult

RemoveChars_Exit:
Exit Function
RemoveChars_Err:
MsgBox Err.Description, vbInformation, Err.Number
Resume RemoveChars_Exit
End Function
Nov 12 '05 #3
One way to do this is by writing code triggered by the OnUpdate event
that evaluates each character in the field and either strips it out,
or checks for the existence of the character in the field and prompts
the user to re-enter the data without those characters.

"Sal" <sl*****@bellatlantic.net> wrote in message news:<ay*******************@nwrdny02.gnilink.net>. ..
How can I prevent same characters from being enter in field on a form.
For example "#$%@"
Please Help
Thanks
Slawek

Nov 12 '05 #4
Put code in the KeyDown or KeyPress event to detect those codes and either
cancel the event or return a 0.

Larry Linson
Microsoft Access MVP

"Sal" <sl*****@bellatlantic.net> wrote in message
news:ay*******************@nwrdny02.gnilink.net...
How can I prevent same characters from being enter in field on a form.
For example "#$%@"
Please Help
Thanks
Slawek

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Antonio Ooi | last post by:
Hi, Probably due to my 'Language for non-Unicode Setting' in Regional Settings, my ASP page keeps outputing the date format as Chinese Simplified characters when issuing say, <%=Now()%>. In...
1
by: Bill | last post by:
How do you prevent the "expand"/"collapse" characters in a resulting XML output file?
7
by: Cues Plus | last post by:
Hello, I have a simple form text area for people to add comments in. The problem is that using the standard <TEXT AREA NAME="comments" ROWS=4 COLS=35></TEXT AREA> Allows people to put in...
5
by: Morris | last post by:
This may not be possible on the server side, so apologies if this is the wrong group for this post. My form consists of an unknown number of pairs of text boxes. They are named textbox_a and...
7
by: Philippe Guglielmetti | last post by:
I spent hours chasing a stupid bug of this kind: std::string bad='x'+"yz"; // results in anything except "xyz" ("yz" was in fact returned by some class::operator char*() conversion...) Any...
9
by: Mike | last post by:
How do I prevent SQL Server 2000 from posting successful backup completion messages to the Windows 2000 Application Event Log? I have scheduled jobs which backup my transaction logs on 50+...
7
by: L Mehl | last post by:
Hello -- In a form text field for entering stock symbols, I want to allow only: alpha integer decimal backspace left and right arrows delete shift
4
by: Sal | last post by:
How can I prevent same characters from being enter in field on a form. For example "#$%@" Please Help Thanks Slawek
1
by: jamesd | last post by:
We have a javascript that is vulnerable to XSS because the input to the script is not being checked for strings such as "javascript", "eval", "script" etc. I have seen some snippets of code here...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.