Duplicate field and repalce space with underscore

  • Thread starter Thread starter Appalachia
  • Start date Start date
A

Appalachia

I have a field that contains City names and need to us it as an HTML Anchor,
so there can't be spaces in the names.

How can I duplicate a field and replace any spaces with an underscore _

Many thanks

SGC
 
I have a field that contains City names and need to us it as an HTML Anchor,
so there can't be spaces in the names.

How can I duplicate a field and replace any spaces with an underscore _

Many thanks

SGC

=Replace([FieldName]," ","_")
 
Thanks

Sorry but I don't know where to put this... =Replace([FieldName]," ","_")

I'm using Access 2007 which looks different from Access 2003.

I made a new field but can't see where to put the code. Is it Validation?

And do I replace FieldName and keep the square brackets or leave them out?

SGC

--
Confusion will be my epitaph...


fredg said:
I have a field that contains City names and need to us it as an HTML Anchor,
so there can't be spaces in the names.

How can I duplicate a field and replace any spaces with an underscore _

Many thanks

SGC

=Replace([FieldName]," ","_")
 
I figured out how to do it in a Query and then Make Table to another DB - is
that the way?

Any way to test for and remove any extranious space(s) at the end of the
origional field contents?

Many thanks


--
Confusion will be my epitaph...


fredg said:
I have a field that contains City names and need to us it as an HTML Anchor,
so there can't be spaces in the names.

How can I duplicate a field and replace any spaces with an underscore _

Many thanks

SGC

=Replace([FieldName]," ","_")
 
I figured out how to do it in a Query and then Make Table to another DB - is
that the way?

It's total overkill, frankly - you could do it with an update query in place,
or even just a select query. If you're assuming that you must have the data in
a Table in order to export it, you don't; you can export a query.
Any way to test for and remove any extranious space(s) at the end of the
origional field contents?

It's very unlikely there are any - Access trims trailing blanks in text fields
- but you could run an Update query using the Trim function:

UPDATE tablename
SET fieldname = RTrim([fieldname])
WHERE fieldname LIKE "* ";

The WHERE criterion will find records ending in a blank, and RTrim will remove
it.
 
Back
Top