Need help with code to remove spaces and punctuation.

lovett10

Registered User.
Local time
Today, 09:15
Joined
Dec 1, 2011
Messages
150
[SOLVED] Need help with code to remove spaces and punctuation.

What i would like to happen is when i press Command34, the information in Text43 and Text44 will have both of their spaces and punctuation removed.

this is because i have a set format on the database which is set to @&&&&&_@&&_@@@ However if the user puts in the correct info but uses "-" instead on "_" the database shows with them both.

Hopefully using the space and punctuation removal code it will change it so that when they hit the Command34 button (the save button) the "-" will be removed in this example so that the database format corrects it when in the database.

Thanks for help in advanced.
 
Last edited:
To do what you ask I would suggest you look into the Replace() function (http://www.techonthenet.com/access/functions/string/replace.php). However, I wouldn't do it like that.

I would instead have a prompt display when the wrong format is entered and let the user manually correct it until they submit it in the correct format. What you are doing is assuming you know what the inputter actually meant, and that may not be the case.

Suppose they just miskeyed a '-' and instead meant a 'p'. Your way would change that '-' to a '_' when it should have been a 'p'. Of course you know more about the situation than anyone, but that's just something to consider.
 
Why force people to type something that you know what is?
 
To do what you ask I would suggest you look into the Replace() function
However, I wouldn't do it like that.

I would instead have a prompt display when the wrong format is entered and let the user manually correct it until they submit it in the correct format. What you are doing is assuming you know what the inputter actually meant, and that may not be the case.

Suppose they just miskeyed a '-' and instead meant a 'p'. Your way would change that '-' to a '_' when it should have been a 'p'. Of course you know more about the situation than anyone, but that's just something to consider.


Firstly thanks for the help.

To give you more information the format will always be a group that consists of LNNNNN then LNN then LLL (L being letter and N number) the problem is how the split the groups of information. some people use spaces some "-" some "/" and so on. What i am asking is if i can remove it so it just show LNNNNNLNNLLL then the database does the rest for me by imputting the "_".

I hope this clears things up and again thanks for the help.
 
But you still require them to type a "_". This can be a Literal and can be saved without users typing it.

Ah ok i see what you mean, Thanks very much for your help really appreciate it.
 
It sounds like you may have 3 discrete pieces of information all stored in the same field. You may want to break this up into 3 fields.

What exactly is this data and does the LNNNNN signify something, does the LNN signify something else and does the LLL signify a third thing?

3 fields would solve your inputting error by avoiding users inputing seperating characters.
 
It sounds like you may have 3 discrete pieces of information all stored in the same field. You may want to break this up into 3 fields.

What exactly is this data and does the LNNNNN signify something, does the LNN signify something else and does the LLL signify a third thing?

3 fields would solve your inputting error by avoiding users inputing seperating characters.


Thanks for your help, its working now
 

Users who are viewing this thread

Back
Top Bottom