Updated part of a field

  • Thread starter Eleanor of Aquitaine
  • Start date
E

Eleanor of Aquitaine

I want to write a query that will update only one character in a field.
Right now the data looks like:
question1_answer1
question2_answer1
question3_answer1

I want it to be:
question1_answer2
question2_answer2
question3_answer2

So I just want to change the last character. Is this possible?
 
K

KARL DEWEY

Back up your database. Back up your database.

Use the Replace function --
Replace([YourTableName].[YourFieldName], "answer1", "answer2")
 
E

Eleanor of Aquitaine

I've only got Access 2003 and I don't think it has the Replace feature.
Sorry, should have mentioned that in the first note.

KARL DEWEY said:
Back up your database. Back up your database.

Use the Replace function --
Replace([YourTableName].[YourFieldName], "answer1", "answer2")


--
KARL DEWEY
Build a little - Test a little


Eleanor of Aquitaine said:
I want to write a query that will update only one character in a field.
Right now the data looks like:
question1_answer1
question2_answer1
question3_answer1

I want it to be:
question1_answer2
question2_answer2
question3_answer2

So I just want to change the last character. Is this possible?
 
K

KARL DEWEY

Try running a select query with a calculated field like this --
Test_Output: Replace([YourTableName].[YourFieldName], "answer1", "answer2")

--
KARL DEWEY
Build a little - Test a little


Eleanor of Aquitaine said:
I've only got Access 2003 and I don't think it has the Replace feature.
Sorry, should have mentioned that in the first note.

KARL DEWEY said:
Back up your database. Back up your database.

Use the Replace function --
Replace([YourTableName].[YourFieldName], "answer1", "answer2")


--
KARL DEWEY
Build a little - Test a little


Eleanor of Aquitaine said:
I want to write a query that will update only one character in a field.
Right now the data looks like:
question1_answer1
question2_answer1
question3_answer1

I want it to be:
question1_answer2
question2_answer2
question3_answer2

So I just want to change the last character. Is this possible?
 
J

John W. Vinson

I want to write a query that will update only one character in a field.
Right now the data looks like:
question1_answer1
question2_answer1
question3_answer1

I want it to be:
question1_answer2
question2_answer2
question3_answer2

So I just want to change the last character. Is this possible?

You need to update the entire field to a new string which differs only in the
last character. For your specific example - updating a field by replacing its
last character (whatever that character might be) to "2" - you could run an
update query updating Myfield to

Left([Myfield], Len([Myfield]) - 1) & "2"

This will evaluate the length of the field; subtract 1 from that length;
extract that many characters from the string; append a literal character 2.
 
E

Eleanor of Aquitaine

Thanks a lot. That worked beautifully.

KARL DEWEY said:
Try running a select query with a calculated field like this --
Test_Output: Replace([YourTableName].[YourFieldName], "answer1", "answer2")

--
KARL DEWEY
Build a little - Test a little


Eleanor of Aquitaine said:
I've only got Access 2003 and I don't think it has the Replace feature.
Sorry, should have mentioned that in the first note.

KARL DEWEY said:
Back up your database. Back up your database.

Use the Replace function --
Replace([YourTableName].[YourFieldName], "answer1", "answer2")


--
KARL DEWEY
Build a little - Test a little


:

I want to write a query that will update only one character in a field.
Right now the data looks like:
question1_answer1
question2_answer1
question3_answer1

I want it to be:
question1_answer2
question2_answer2
question3_answer2

So I just want to change the last character. Is this possible?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top