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
Using Update query to change a part of a value?
Collapse
X
-
Tags: None
-
Originally posted by DeManHi 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 enquiryComment
-
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.
Code:UPDATE tblTable SET tblTable.lastName = "de Pedro" WHERE (((tblTable.lastName)="De Pedro"))
Comment
-
Originally posted by JKingStart 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.
Code: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. RustyComment
-
Alright this should be more along the lines of what you want.
Code:UPDATE tblTable SET tblTable.lastName = Replace([tblTable]![lastName],"De","de") WHERE (((tblTable.lastName) Like "De*"));
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.Comment
-
Originally posted by JKingAlright this should be more along the lines of what you want.
Code:UPDATE tblTable SET tblTable.lastName = Replace([tblTable]![lastName],"De","de") WHERE (((tblTable.lastName) Like "De*"));
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.Comment
-
Originally posted by JKingAlright this should be more along the lines of what you want.
Code:UPDATE tblTable SET tblTable.lastName = Replace([tblTable]![lastName],"De","de") WHERE (((tblTable.lastName) Like "De*"));
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.Comment
-
Originally posted by JKingI overlooked one small aspect. You need to add a space in LIKE in the where clause
Code:WHERE (((tblTable.lastName) Like "De *"));
Comment
-
Originally posted by JKingI overlooked one small aspect. You need to add a space in LIKE in the where clause
Code:WHERE (((tblTable.lastName) Like "De *"));
Comment
-
Originally posted by JKingCan 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...Comment
-
Originally posted by JKingCan you paste me your sql? That last one should work I tested it out with the space.Comment
Comment