472,338 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,338 software developers and data experts.

Using Update query to change a part of a value?

I am working in MS Access 2003 and I want to use the update query to change part of a value in a field. I have a last name field that contains a lot of records. Someone entered the values De Pedro and De La Rosa etc. and my boss wants them in lower case de Pedro and de la Rosa. I want to update De to de without having to manually change them. I tried criteria Like *De* and update *"de"* but the whole name is replaced with de. How can I replace De with de without overwriting the rest of the name? I would appreciate your expertise. Rusty
Jun 18 '07 #1
15 20197
DeMan
1,806 1GB
Hi Ms Rusty Boyd,

I'll just move this thread to the access forum, where better qualified experts are more likely to see it......

I hope they can help you with your enquiry
Jun 18 '07 #2
Hi Ms Rusty Boyd,

I'll just move this thread to the access forum, where better qualified experts are more likely to see it......

I hope they can help you with your enquiry
I appreciate your assistance, I am new to this environment. Rusty
Jun 18 '07 #3
JKing
1,206 Expert 1GB
Start a new query and enter sql view. Enter the below SQL replacing tblTable with the name of the table you want to update and lastName with the field name you want to update. Access will prompt you asking if it's alright to change x amount of records. After completion just change "de Pedro" and "De Pedro" to "de la Rosa" and "De La Rose" respectively.

Expand|Select|Wrap|Line Numbers
  1. UPDATE tblTable SET tblTable.lastName = "de Pedro"
  2. WHERE (((tblTable.lastName)="De Pedro"))
  3.  
Jun 18 '07 #4
Start a new query and enter sql view. Enter the below SQL replacing tblTable with the name of the table you want to update and lastName with the field name you want to update. Access will prompt you asking if it's alright to change x amount of records. After completion just change "de Pedro" and "De Pedro" to "de la Rosa" and "De La Rose" respectively.

Expand|Select|Wrap|Line Numbers
  1. UPDATE tblTable SET tblTable.lastName = "de Pedro"
  2. WHERE (((tblTable.lastName)="De Pedro"))
  3.  

How can I do this with wildcards? I want it to find DE no matter what last name it is included in and convert it to "de" while leaving the rest of the name in tact. Thank you for your interest. Rusty
Jun 18 '07 #5
JKing
1,206 Expert 1GB
Alright this should be more along the lines of what you want.

Expand|Select|Wrap|Line Numbers
  1. UPDATE tblTable SET tblTable.lastName = Replace([tblTable]![lastName],"De","de")
  2. WHERE (((tblTable.lastName) Like "De*"));
  3.  
The Replace Function's parameters are (stringExpression, find, replace)
Searches the first string for the second string and replaces the second with the third string within the first string.

Try that and let me know how it turn's out.
Jun 18 '07 #6
Alright this should be more along the lines of what you want.

Expand|Select|Wrap|Line Numbers
  1. UPDATE tblTable SET tblTable.lastName = Replace([tblTable]![lastName],"De","de")
  2. WHERE (((tblTable.lastName) Like "De*"));
  3.  
The Replace Function's parameters are (stringExpression, find, replace)
Searches the first string for the second string and replaces the second with the third string within the first string.

Try that and let me know how it turn's out.
I most definitely will try it. Thank you.
Jun 18 '07 #7
JKing
1,206 Expert 1GB
I overlooked one small aspect. You need to add a space in LIKE in the where clause

Expand|Select|Wrap|Line Numbers
  1. WHERE (((tblTable.lastName) Like "De *"));
  2.  
Otherwise any names such as Del'Monte or Demitri would also have the d put to lower case.
Jun 18 '07 #8
Alright this should be more along the lines of what you want.

Expand|Select|Wrap|Line Numbers
  1. UPDATE tblTable SET tblTable.lastName = Replace([tblTable]![lastName],"De","de")
  2. WHERE (((tblTable.lastName) Like "De*"));
  3.  
The Replace Function's parameters are (stringExpression, find, replace)
Searches the first string for the second string and replaces the second with the third string within the first string.

Try that and let me know how it turn's out.
I got the reply You are about to update 0 records. Back to the drawing board.
Jun 18 '07 #9
I overlooked one small aspect. You need to add a space in LIKE in the where clause

Expand|Select|Wrap|Line Numbers
  1. WHERE (((tblTable.lastName) Like "De *"));
  2.  
Otherwise any names such as Del'Monte or Demitri would also have the d put to lower case.
I copied and pasted your code and replaced the table and field name but it still said "You are about to replace 0 records."
Jun 18 '07 #10
JKing
1,206 Expert 1GB
Can you paste me your sql? That last one should work I tested it out with the space.
Jun 18 '07 #11
I overlooked one small aspect. You need to add a space in LIKE in the where clause

Expand|Select|Wrap|Line Numbers
  1. WHERE (((tblTable.lastName) Like "De *"));
  2.  
Otherwise any names such as Del'Monte or Demitri would also have the d put to lower case.
I would love to know how to do this in a query, but what you said about adding the space gave me a clue to a low-tech solution. I went to Find & Replace and set the Find to space De space and the de done the same way and it worked. Thank you for setting me on a productive path. If you come up with an Update query solution I would still appreciate knowing how to change some of the value while leaving the rest in tact. Thanks again, Rusty
Jun 18 '07 #12
Can you paste me your sql? That last one should work I tested it out with the space.

UPDATE Cities SET Cities.LName = Replace([Cities]![LName],"De","de")
WHERE (((Cities.LName) Like "De *"));

Here it is...
Jun 18 '07 #13
Can you paste me your sql? That last one should work I tested it out with the space.
I couldn't let it go after you said yours worked, you're right. I put a space after the first astrisk also "* De *" and it did work. Thank you so so much. Rusty
Jun 18 '07 #14
JKing
1,206 Expert 1GB
Great! I'm glad things worked out.

JKing
Jun 19 '07 #15
rokgod7
1 Bit
@Ms Rusty Boyd
This thread was very helpful, and I was able to accomplish my task, which was similar to the original question. If you don't want to use the SQL view, but instead want to do it in the design view, you can do it in the SQL view once, and then switch over to the design view, and see how it did it for you. From there, you can use that methodology, and modify it as needed.
3 Weeks Ago #16

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: PG | last post by:
When deleting a row from the database, that id is now missing. So what I'm trying to do is update in a loop (maybe an sql loop if there is one) of...
5
by: rdraider | last post by:
Hi all, I'm looking for a way to re-number inventory items. The items exist in 50+ tables, hundreds of fields and there are several thousand...
2
by: CSN | last post by:
Is it possible to update the timezone part of timestamp fields in a single query? I have a bunch of values that are -06 I need changed to -07. ...
5
by: chris vettese | last post by:
I have a table called table1 that has a one to many relationship to table2. What I would like to do is have a form with two list boxes on it. The...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) ...
4
by: jay | last post by:
I am using the dataset object to add a row to a sql server database in vb.net code, as follows: dim drow as DataRow dim cmdBld as new...
14
by: Peter Hallett | last post by:
I would like to set up a string array as a class member, or field, and then populate this array by reading in from a text file, but I cannot find...
1
by: ansc1 | last post by:
Hello, I'm new to using php coding. I need help with the following: 1. There is a submit button on the form and is saves information to my...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.