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
15 20197
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
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
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. -
UPDATE tblTable SET tblTable.lastName = "de Pedro"
-
WHERE (((tblTable.lastName)="De Pedro"))
-
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. -
UPDATE tblTable SET tblTable.lastName = "de Pedro"
-
WHERE (((tblTable.lastName)="De Pedro"))
-
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
Alright this should be more along the lines of what you want. -
UPDATE tblTable SET tblTable.lastName = Replace([tblTable]![lastName],"De","de")
-
WHERE (((tblTable.lastName) Like "De*"));
-
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.
Alright this should be more along the lines of what you want. -
UPDATE tblTable SET tblTable.lastName = Replace([tblTable]![lastName],"De","de")
-
WHERE (((tblTable.lastName) Like "De*"));
-
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.
I overlooked one small aspect. You need to add a space in LIKE in the where clause -
WHERE (((tblTable.lastName) Like "De *"));
-
Otherwise any names such as Del'Monte or Demitri would also have the d put to lower case.
Alright this should be more along the lines of what you want. -
UPDATE tblTable SET tblTable.lastName = Replace([tblTable]![lastName],"De","de")
-
WHERE (((tblTable.lastName) Like "De*"));
-
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.
I overlooked one small aspect. You need to add a space in LIKE in the where clause -
WHERE (((tblTable.lastName) Like "De *"));
-
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."
Can you paste me your sql? That last one should work I tested it out with the space.
I overlooked one small aspect. You need to add a space in LIKE in the where clause -
WHERE (((tblTable.lastName) Like "De *"));
-
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
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...
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
Great! I'm glad things worked out.
JKing
@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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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.
...
|
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...
|
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)
...
|
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...
|
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...
|
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...
|
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...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
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...
|
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...
|
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...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
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.
...
|
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...
|
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...
|
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...
| |