A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

I do not want to allow any special characters to be entered into a field



 
 
Thread Tools Display Modes
  #1  
Old December 13th, 2004, 05:07 PM
moe leaer via AccessMonster.com
external usenet poster
 
Posts: n/a
Default I do not want to allow any special characters to be entered into a field

I currently have part numbers that have DASHES in various locations throughout the alpha numeric number. I have convinced the company that for sorting and Database reasons it would be better if users do NOT enter the dashes in the database.

I would like to set up something that would either not allow them to enter the -'s or even better, just remove them automatically before the form print function.

The INPUT Mask function sort of does what I want, but OUR alpha numeric part numbers are of various lengths, from 4-20 characters. It seems to put place holders in the remanding places that are a bit strange looking.

Any Ideas, thanks for the help!

Moe

--
Message posted via http://www.accessmonster.com
  #2  
Old December 13th, 2004, 06:40 PM
Duane Hookom
external usenet poster
 
Posts: n/a
Default

I hate input masks so I would use code in the form to either ignore the "-"
or replace is with "" following the updating of the control.
Private Sub txtPartNum_KeyPress(KeyAscii As Integer)
'ignore the "-"
If KeyAscii = Asc("-") Then
KeyAscii = 0
End If
End Sub

--
Duane Hookom
MS Access MVP


"moe leaer via AccessMonster.com" wrote in message
news:b71407eac4ee4bbbbfa464980c0ca00b@AccessMonste r.com...
I currently have part numbers that have DASHES in various locations

throughout the alpha numeric number. I have convinced the company that for
sorting and Database reasons it would be better if users do NOT enter the
dashes in the database.

I would like to set up something that would either not allow them to enter

the -'s or even better, just remove them automatically before the form print
function.

The INPUT Mask function sort of does what I want, but OUR alpha numeric

part numbers are of various lengths, from 4-20 characters. It seems to put
place holders in the remanding places that are a bit strange looking.

Any Ideas, thanks for the help!

Moe

--
Message posted via http://www.accessmonster.com



  #3  
Old December 13th, 2004, 07:08 PM
John Vinson
external usenet poster
 
Posts: n/a
Default

On Mon, 13 Dec 2004 17:07:41 GMT, "moe leaer via AccessMonster.com"
wrote:

I currently have part numbers that have DASHES in various locations throughout the alpha numeric number. I have convinced the company that for sorting and Database reasons it would be better if users do NOT enter the dashes in the database.


Good! I'd hate to think that "A312-2" and "A31-22" would both be valid
part numbers, whether they refer to the same part or to different
parts.

I would like to set up something that would either not allow them to enter the -'s or even better, just remove them automatically before the form print function.


What does the "print" function have to do with anything!? You're not
printing a Form, I hope?

The INPUT Mask function sort of does what I want, but OUR alpha numeric part numbers are of various lengths, from 4-20 characters. It seems to put place holders in the remanding places that are a bit strange looking.

Any Ideas, thanks for the help!


Two suggestions:

- Use the BeforeUpdate event of the part number textbox to chide the
user for invalid part numbers:

Private Sub txtPartNo_BeforeUpdate(Cancel as Integer)
If InStr(txtPartNo, "-") 0 Then
MsgBox "Please, no hyphens!", vbOKOnly
Cancel = True
End If

Or, a bit more code: use the AfterUpdate event (sounds illogical but
it's the correct event) to strip them out:

Private Sub txtPartNo_AfterUpdate()
Dim iPos As Integer
Dim sChr As String
Dim sFix As String
txtPartNo = UCase(txtPartNo) ' upper case all text
sFix = ""
For iPos = 1 to Len(txtPartNo)
sChr=Mid(txtPartNo, iPos, 1)
If (Asc(sChr) = 48 And Asc(sChr) = 57) ' digits
Or (Asc(sChr) = 65 And Asc(sChr) = 90) Then ' letters
sFix = sFix & sChr
Else
' either do nothing, or
' MsgBox "Stripping out invalid part number characters", vbOKOnly
End If
Next iPos
txtPartNo = sFix
End Sub

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Special Characters jintag General Discussion 2 September 18th, 2004 12:32 AM
Count characters in a field Christine Running & Setting Up Queries 2 September 15th, 2004 06:27 PM
using paste special within a word doc Julie General Discussion 4 July 22nd, 2004 05:37 AM
Supress blank lines in DOCPROPERTY field Mary Formatting Long Documents 10 May 25th, 2004 07:27 PM
Removing leading characters from word field Peter Wilde Mailmerge 2 May 4th, 2004 12:01 PM


All times are GMT +1. The time now is 01:58 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.