Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Literal pound sign 1

Status
Not open for further replies.

ptpaton

IS-IT--Management
Apr 22, 2003
124
US
Hi all,

I'm trying to prevent a user from entering the pound sign (#) into a text box. The text box is used to rename a file using fs.CopyFile. That file is then linked via html, and when the user attempts to follow the link to the file, if a pound sign is in the path, Access thinks it's actually a bookmark or target in the file, and the file cannot be found.

I'm thinking about a simple validation rule, such as Not Like "*#*", but Access intreprets the # sign as any number format. Thus, with "*#*" as the validation rule, Access allows the pound sign, but prevents any number from being entered. I know the pound sign refers to a number format, but I don't know how to reference the actual pound sign. Anyone know how to prevent the literal # sign from being entered?

Thanks

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Sorry all, never mind. Access allows the pound sign in an HTML link. If anyone knows how to reference the pound sign though, I'm still interested.

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Try Using:
************************************************************
Private Sub (YourTextboxname)_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8 ' backspace/delete
' always allow this key
Case 9 To 34
Case 36 To 255
Case 48 To 57 ' Asc("0") to Asc("9")
' allow these characters
Case Else
' reject these characters
KeyAscii = 0
End Select
End Sub
************************************************************
Every time the user tries to enter the # sign the routine will reset the key press character to zero thus not allowing that particular character.

HTH

G.

 
Works great G. Thanks! I like it too, much cleaner than a validation rule.

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top