Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mimic Find/Replace functionality via VBA 1

Status
Not open for further replies.
Oct 13, 2004
39
US
Hello all -

I have a database table that has a column of usernames.

the usernames have the domain attached into it. I am looking to strip this domain and leave only the username.

so for example..

home/JDoe
home/WSmith
home/BMorris
home/MHunt
home/JMama

...would be possible values of the column.

I would like to strip the domain from the data cell so that it instead reads...

JDoe
WSmith
BMoris
etc.

I currently do this manually quite well by selecting the column and using the find replace for "home/" and it achives the desired result.

Unfortuantely this is several steps to many and need to be able to do this from a form command button that would trigger this behaviour

Thanks in advance for any insight, suggestions, and/or code!!
 
Is the domain name constant ie is it always 'home/'? If it is just look up the VBA 'mid' command, it's an easy one to understand.
 
yea i saw the mid function as well as the replace function but i am unclear on how to run these against the data in the table.

how do you shoot the tabel data from that single column into this function and then how do you send it back and replace it??

Thanks anyway!!
 
UPDATE yourTable
SET username=Mid([username],InStr([username],'/')+1)
WHERE username Like '*/*'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top