From outside Access. I am running it using the Jet Engine connection string.
When I try Replace I get "undefined function Replace". From reading the
forums, I realize that the Jet does not have a Replace function and you
cannot use a UDF. Wondering what is the next best thing.
SELECT Replace(Replace([Field1], ":", "_"), "-", "_") AS Field2 FROM Table1;
Someone from work suggested something like the following (they were trying
to Replace tildas)
SELECT *,
IIF(INSTR(FieldID, '~') > 0 AND INSTR(FieldID, '(') = 0,
MID(FieldID, 1, INSTR(FieldID, '~') - 1)
+ '_' + MID(FieldID, INSTR(FieldID, '~') + 1)
,
IIF(INSTR(FieldID, '~') > 0 AND INSTR(FieldID, '(') > 0,
MID(FieldID, 1, INSTR(FieldID, '~') - 1)
+ '_' + MID(FieldID, INSTR(FieldID, '~') + 1, INSTR(FieldID, '(') -
INSTR(FieldID, '~') - 1)
+ '_' + MID(FieldID, INSTR(FieldID, '(') + 1, INSTR(FieldID, ')') -
INSTR(FieldID, '(') - 1)
+ '_' + MID(FieldID, INSTR(FieldID, ')') + 1)
,
IIF(INSTR(FieldID, '~') = 0 AND INSTR(FieldID, '(') > 0,
MID(FieldID, 1, INSTR(FieldID, '(') - 1)
+ '_' + MID(FieldID, INSTR(FieldID, '(') + 1, INSTR(FieldID, ')') -
INSTR(FieldID, '(') - 1)
+ '_' + MID(FieldID, INSTR(FieldID, ')') + 1)
,
FieldID
))) AS FunctionName
FROM Table1
Douglas J. Steele said:
Are you attempting to run this from within Access, or using some other
application? If Access, what version?
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
I am writing an SQL statement that will be used by the Jet Engine. I want
to
take field1 and replace all '-' and ":" with '_'. How can I do this? Have
tried using the following but "replace" is not found. have also tried my
own
REPLACE1 function, but it is still not found.
Select *, replace(field1, '-', '_') as field2 from table1