Solved

Access 2003, Update Query is killing my text

Posted on 2009-03-31
3
246 Views
Last Modified: 2013-11-27
I have a field called [QPR/QPI Number] in a table called  SkpiUpdate.
I need to clean all the special characters from the field.

However when I run the below Update query it clears out many of fields from the record set.
Currently there are 93 fields that are NULL in this field after I run the query there are 134 NULL records.

All I am trying to do is remove the "-" from a couple of the records. The field is a text field. Mostly all numbers though. (Which is fine)

Here is my SQL: ( I use this in another area and it works fine)
UPDATE SkpiUpdate SET SkpiUpdate.[QPR/QPI Number] = Replace(Mid([QPR/QPI Number],8),"-","");
0
Comment
Question by:ggodwin
3 Comments
 
LVL 5

Expert Comment

by:defi0
Comment Utility
If your field contains a value but does not contain a '-' after the 7th character, it will indeed be nullified. You should first test that Mid([QPR/QPI Number],8) contains a dash. Also, is it normal that it gets rid of the first character in all cases?
0
 

Author Comment

by:ggodwin
Comment Utility
Is there easier way to just remove all the "-"?
Now that I think about it. I am not sure where this query came from?
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 250 total points
Comment Utility
Your query is stripping first 7 chars and replacing all - from 8th character

Does that ring any bells?

If u just want to remove the dashs, you can just use replace without using the mid


update mytable set myfield = replace(myfield,"-","")

be warned, it will remove ALL occurrences. It may not be what you want. Before big changes, its recommended to backup db
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now