Repace space with a charater

  • Thread starter Thread starter Simon
  • Start date Start date
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 _
 
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
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top