Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

string comparision in access

Posted on 2005-03-28
7
Medium Priority
?
236 Views
Last Modified: 2008-01-09
hi ,
I need to update all rows in a table only for a certain field.
however i only need to update the value starting from position 5 to 3 byes.
like
update table_a
set field_a(5,3) = "555"

but i do not know the proper syntax.
thanks
0
Comment
Question by:chakrika
  • 4
  • 2
7 Comments
 
LVL 10

Expert Comment

by:perkc
ID: 13648011
Use the 'Replace' function:

UPDATE table_a
SET field_a = replace([table_a]![field_a],5,3,"555");

perkc
0
 

Author Comment

by:chakrika
ID: 13652051
Hi i tried to do that. but i get the following  error message:
Microsoft Access didn't update 0 field(s) due to a type conversion failure, 0 records(s) due to key violations, 0 records(s) due to lock violations, and 32 record(s) due to validation rule violations Do you want to continue running this type of action query anyway? To ignore the error(s) and run the query, click yes. For an explanation of the causes of the violations, click Help.
0
 

Author Comment

by:chakrika
ID: 13652185
I changed teh query to do this.
UPDATE table_a
SET field_a = replace(5,3,"555");

but then it replaced the entire value in the table with onlyjust '5'.

thanks
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:chakrika
ID: 13652373
ok i understand that the replace function should be used like this
REPLACE(old_text,start_num,num_chars,new_text)

 
But still i get the error message i mentioned above. I cannot update.
0
 
LVL 10

Expert Comment

by:perkc
ID: 13652759
Give me a couple of examples of the type of values that you have in the 'field_a' field.

Also, what format is the field_a table field? Text? Number?
0
 
LVL 2

Accepted Solution

by:
kalios earned 720 total points
ID: 13653115
chakrika, use something like this.
lets say the field_a is 10 bytes. so use this:

UPDATE table_a
SET table_a.[field_a] = MID(table_a.[field_a],1,4) & "555" & MID(table_a.[field_a],8,3);

Kalios
0
 

Author Comment

by:chakrika
ID: 13653130
super kalios.

works like a charm
thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question