By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,490 Members | 1,774 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,490 IT Pros & Developers. It's quick & easy.

A2K - prevent "/" being input

P: n/a
When creating a record the user is asked to enter some description. They
are free to enter anything they like (it's a text field).
However I use the "/" as a separator when I append some extra text onto what
the user has entered;

e.g
Ths is a note / My data

The user has nothing to do with the "My data" string.

However if they use "/" in their description is messes up my control over
the final string, when they come to edit the description later on.

To cut a long story short it would be nice if the only thing they could NOT
enter would be the "/".

My googling has not come up with anything, though it could be me (slightly
warm in blighty today you see :) )

ta
Martin

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi
In the afterupdate use something like this
If InStr([txtStDesc1], "/") > 0 Then
txtStDesc1 = Replace(txtStDesc1, "/", "\")
End If
the / will be replaced with \ or whatever you like
Alfred
"Deano" <de*********@hotmail.com> wrote in message
news:xo*********************@stones.force9.net...
When creating a record the user is asked to enter some description. They
are free to enter anything they like (it's a text field).
However I use the "/" as a separator when I append some extra text onto what the user has entered;

e.g
Ths is a note / My data

The user has nothing to do with the "My data" string.

However if they use "/" in their description is messes up my control over
the final string, when they come to edit the description later on.

To cut a long story short it would be nice if the only thing they could NOT enter would be the "/".

My googling has not come up with anything, though it could be me (slightly
warm in blighty today you see :) )

ta
Martin

Nov 13 '05 #2

P: n/a
On Tue, 8 Jun 2004 11:19:45 +0100, Deano wrote:
When creating a record the user is asked to enter some description. They
are free to enter anything they like (it's a text field).
However I use the "/" as a separator when I append some extra text onto what
the user has entered;

e.g
Ths is a note / My data

The user has nothing to do with the "My data" string.

However if they use "/" in their description is messes up my control over
the final string, when they come to edit the description later on.

To cut a long story short it would be nice if the only thing they could NOT
enter would be the "/".

My googling has not come up with anything, though it could be me (slightly
warm in blighty today you see :) )

ta
Martin


The "/" is a common symbol used for division and in internet
addresses. Perhaps you would be well served to change "your" separator
symbol to something else. I would suggest the back slash "\" but even
that is used in computer path addresses and perhaps might appear
normally in the field.
Why not use AutoCorrect to replace 2 verticle pipes "||" or even 3 of
them (to make inadvertent entry more difficult), with a bullet and use
the bullet as your text separator. The Bullet is chr(149). When used,
Access will display it on your form as a thick pipe, but will print
the bullet in a report.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #3

P: n/a
fredg wrote:

< snipped>

The "/" is a common symbol used for division and in internet
addresses. Perhaps you would be well served to change "your" separator
symbol to something else. I would suggest the back slash "\" but even
that is used in computer path addresses and perhaps might appear
normally in the field.
Why not use AutoCorrect to replace 2 verticle pipes "||" or even 3 of
them (to make inadvertent entry more difficult), with a bullet and use
the bullet as your text separator. The Bullet is chr(149). When used,
Access will display it on your form as a thick pipe, but will print
the bullet in a report.


Thanks for the ideas. I think I will go with Alfred's code which works
nicely. It would be too much work to go back and recode stuff, so the
option of papering over my less than ideal design is most appealing :)
Nov 13 '05 #4

P: n/a
Alfred wrote:
Hi
In the afterupdate use something like this
If InStr([txtStDesc1], "/") > 0 Then
txtStDesc1 = Replace(txtStDesc1, "/", "\")
End If
the / will be replaced with \ or whatever you like
Alfred


Thanks Alfred, that's quite effective.
Nov 13 '05 #5

P: n/a
"Deano" <de*********@hotmail.com> wrote in
news:xo*********************@stones.force9.net:
When creating a record the user is asked to enter some description.
They are free to enter anything they like (it's a text field).
However I use the "/" as a separator when I append some extra text
onto what the user has entered;

e.g
Ths is a note / My data

The user has nothing to do with the "My data" string.

However if they use "/" in their description is messes up my control
over the final string, when they come to edit the description later
on.

To cut a long story short it would be nice if the only thing they
could NOT enter would be the "/".


You could use the Key press event for you field.
The code could be something like this

Private Sub product_code_KeyPress(KeyAscii As Integer)
if KeyAscii = Asc("/") then
KeyAscii = 0
end if
End Sub

The user will not see the "/" at all.

Or a little bit more advanced, this will prevent the user from
inputting "/" "|" and numbers

Private Sub product_code_KeyPress(KeyAscii As Integer)
if not (chr(KeyAscii) like "[/|0-9]") then
KeyAscii = 0
end if
End Sub
--
Rolf
Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.