Deleting first characters in a field

  • Thread starter Thread starter Michelle
  • Start date Start date
M

Michelle

In an update query how would I delete the first 9
characters of a field. Example I want domainname\username
to return just the username.

Thanks!
Michelle
 
I figured this part out.

How do I get this to run everytime something is added to
the table?
 
Alright, thought I had it but I need this to run more
than once. As new records are captured through a web site
they come in with the domainname\username format but I
don't want the data stored in that format. I am very
green with this so if anyone could help.

I was using the following in an update query

UPDATE hrresults SET hrresults.user_name = Right
(user_name, Len(user_name) -8)

As I said, this worked but I obviously can't continue to
run it.

Any help would be GREATLY appreciated.
 
You could use:

UPDATE hrresults SET hrresults.user_name = Right
(user_name, Len(user_name) -8)
WHERE user_name like "domain\*"

(replacing domain with the approrpriate expression, of course)

But why not leave the domain there (in case you ever need it again), and
simply have a query that strips the domain off? In fact, you could have:

SELECT user_name, Left(user_name, InStr(user_name, "\")-1) AS user_domain,
Mid(user_name, InStr(user_name, "\")+1) AS user_name_no_domain
 
Thanks for the info. Now, I'm very green so I couldn't
get the select statement to work right. Here's a little
more info. I based a DAP off of the query, included in
this is a prompt for the user to enter their username to
only display their information (doesn't matter if they
see others, it's just a way to minimize the information
they have to go through). So in that field I want to
exclude the domain and just have the username remain.
When I use that select statement I get an error that
says "The syntax of the subquery in this expression is
incorrect. Check the subquery's syntax and enclose the
subquery in parentheses" I'm trying to teach myself as I
go but I'm stuck right here.

Thanks Again!
 
Back
Top