Solved

Access 2003, Update Query is killing my text

Posted on 2009-03-31
3
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Expert Comment

by:defi0
ID: 24030854
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
ID: 24030933
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
ID: 24030987
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

617 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