Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access 2003, Update Query is killing my text

Posted on 2009-03-31
3
Medium Priority
?
288 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
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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

971 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