tags:

views:

157

answers:

1

I need to remove hyphens from a string in a large number of access fields. What's the best way to go about doing this?

Currently, the entries are follow this general format:

  2010-54-1
  2010-56-1
  etc.

I'm trying to run append queries off of this field, but I'm always getting validation errors causing the query to fail. I think the cause of this failure is the hypens in the entries, which is why I need to remove them.

I've googled, and I see that there are a number of formatting guides using vbscript, but I'm not sure how I can integrate vb into Access. It's new to me :)

Thanks in advance, Jacques

EDIT:

So, Ive run a test case with some values that are simply text. They don't work either, the issue isn't the hyphens.

A: 

I'm not sure that the hyphens are actually the problem without seeing sample data / query but if all you need to do is get rid of them, the Replace function should be sufficient (you can use this in the query)

example: http://www.techonthenet.com/access/functions/string/replace.php

If you need to do some more advanced string manipulation than this (or multiple calls to replace) you might want to create a VBA function you can call from your query, like this:

http://www.pcreview.co.uk/forums/thread-2596934.php

To do this you'd just need to add a module to your access project, and add the function there to be able to use it in your query.

AlexCuse
Unfortunately, the Find/Replace function only works for up to 65,000 entries. I've got at least 10x that amount :/
Jacques Tardie
Where do you get that number? I haven't used access much lately but don't recall any such limitations regarding the number of rows a function would work on (perhaps someone more knowledgeable w/ access will be more helpful)Are you trying to do this while viewing the dataset, or using a query?
AlexCuse
I tried doing it! Clipboard won't handle any more values than that.I'm doing some really simple work, just trying to append one field to another table, but I'm consistently getting validation errors on every entry.I haven't tried the vb function yet, to be honest mainly because it's not something I'm familiar with at all.
Jacques Tardie
Btw, thanks for the help Alex.
Jacques Tardie
Ah, I see. Looking at your followup comments, I think we'll need to see the query in question to get an idea of what it is you need to do (HansUp describes how you can get the query text to show us)
AlexCuse
@Jacques Tardie: you obviously didn't read the link that @AlexCuse posted, which refers to the Replace() VBA function, which can be used in an UPDATE query from within Access. No one at any point was suggesting using the UI's Find/Replace function.
David-W-Fenton