Repace space with a charater

S

Simon

i have a field on a formcalled txtProductName i would like a button on
the form that will create a file name for the prouduct

exampls
Product Name - Caribbean Blue - Acrylic Surface
Then press a button then in text field txtFileName it will creat the
following
Caribbean_Blue_-_Acrylic_Surface

So i need a way to replace all spaces with _
 
T

Tom Wickerath

Hi Simon,

Assuming you are using Access 2000 or later, you have the built-in Replace
function available to you:

Syntax
Replace(expression, find, replace[, start[, count[, compare]]])

Example in Immediate Window (open with <Ctrl><G>):

?Replace("Caribbean Blue - Acrylic Surface", Chr(32), "_")

Chr(32) calls the built in Chr (Character) function, with the ASCII value of
32, which corresponds to a space. So, Chr(32) is the "find" parameter shown
above in the syntax statement.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
Top