Solved Exclude a character (Apostrophe) in an input field of a form (1 Viewer)

Rich77

New member
Local time
Today, 11:07
Joined
Dec 26, 2023
Messages
9
In a form, an apostrophe may not be used in an input field (all other characters do not cause a problem). There are 2 options to solve this:
1. If the apostrophe is used, it will automatically be replaced by an underscore (with action "Replace").
2. If the apostrophe is used, a messagebox will warn you: "Apostrophe is not allowed" and you must first use another character.
I can't quite manage to implement either of these options without using a lot of VBA code.
Can anyone help me to solve this easily?
 

Rich77

New member
Local time
Today, 11:07
Joined
Dec 26, 2023
Messages
9
In a form, an apostrophe may not be used in an input field (all other characters do not cause a problem). There are 2 options to solve this:
1. If the apostrophe is used, it will automatically be replaced by an underscore (with action "Replace").
2. If the apostrophe is used, a messagebox will warn you: "Apostrophe is not allowed" and you must first use another character.
I can't quite manage to implement either of these options without using a lot of VBA code.
Can anyone help me to solve this easily?
Sorry, I'm new and posted this thread in the wrong forum.
I posted now in the Forms-forum.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:07
Joined
Sep 12, 2006
Messages
15,656
I would warn the user to avoid the apostrophe in the before update event of any text field.

The apostrophe is chr(39) so

If instr(fieldname, chr(39)) >0 then
Msgbox "Sorry. Apostrophe not allowed"
Cancel =true
Exit sub
End if

Sorry, it's chr(39)
Chr(34) is a double quote mark.
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:07
Joined
Sep 21, 2011
Messages
14,301
Show what you have tried?
Why no ' ?
What if you have O'Brien?
 

Rich77

New member
Local time
Today, 11:07
Joined
Dec 26, 2023
Messages
9
I would warn the user to avoid the apostrophe in the before update event of any text field.

The apostrophe is chr(39) so

If instr(fieldname, chr(39)) >0 then
Msgbox "Sorry. Apostrophe not allowed"
Cancel =true
Exit sub
End if

Sorry, it's chr(39)
Chr(34) is a double quote mark.
Great, that's what I'm looking for.
Works fine, thanks,
Richard
 

Users who are viewing this thread

Top Bottom