Can I call on this function in a query? If so, should I
just change the 'Function' to 'Public Function' or are
there changes I should make?
Thanks!
-----Original Message-----
The Replace function was introduced with Access 2000.
You are using Access 97,
correct?
If that is the case, you will need to write the replace
function from scratch in
VBA or simpler copy this one from
http://www.mvps.org/access/strings/str0004.htm
Ken wrote:
That is what i have and it is not working. It keeps
telling me Compile Error: sub or function not defined.
When the error appears the Public Function line is
highlighted in yellow and the ....Replace... part of the
second line is highlieghted in blue. Could it be an
update or something that I am missing?
Thanks, again, for all your help!
-----Original Message-----
Your function now should look like this:
Public Function fReplace(strStringValue As String,
strCurrString As
String, strNewString As String)
fReplace = Replace(strStringValue,
strCurrString,
strNewString)
End Function
This function should be in a regular module; name that
regular module
basFunctions.
Your expression in the query should look like this:
fReplace([Last],Mid([Last],InStr
([Last],","),1),"")
Is this what you now have? And this is not working?
--
Ken Snell
<MS ACCESS MVP>
I am still getting that same message. Frustrating,
isn't
it??
Thanks,
Ken
-----Original Message-----
try renaming your function to fReplace. As it
stands
now, you are recursively
calling your replace function and not the built- in
VBA
function. So it should
just loop until you run out of stack space.
Public Function fReplace(strStringValue As String,
strCurrString As String, strNewString As String)
fReplace = Replace(strStringValue, strCurrString,
strNewString)
End Function
fReplace([Last],",","")
Ken wrote:
Function in Module named: modReplace
Public Function Replace(strStringValue As String,
strCurrString As String, strNewString As String)
Replace = Replace(strStringValue, strCurrString,
strNewString)
End Function
Expression in query:
Replace([Last],Mid([Last],InStr ([Last],","),1),"")
I have also tried:
Replace([Last],",","")
Thank you, once again, for all your help! I
really
appreciate it!!
Ken
-----Original Message-----
Post what your expression and your function are
now.
Let's see what you are
using.
--
Ken Snell
<MS ACCESS MVP>
message
I am getting the same error. Any suggestions?
Just
not
sure where I am going wrong.
Thanks, again!
Ken
-----Original Message-----
I believe that John Spencer has pinpointed the
error in
your function setup.
Post back if not.
--
Ken Snell
<MS ACCESS MVP>
message
[email protected]...
I am using Access '97 and I am not familiar
with
writing
public functions. I tried creating a
module,
but
that
did
not work. Is there any help you can provide
with
this
regard?
Thank you so much for your help!
Ken
-----Original Message-----
Use the Replace function in a calculated
field:
SSNNoDash: Replace([SSNFieldName], "-
", "")
This will work in ACCESS 2002 and in 2000
version
with
updated SP version of
Jet.
Else write your own public function that
uses
the
Replace
function as noted
above and then call that function from your
calculated
field.
--
Ken Snell
<MS ACCESS MVP>
message
[email protected]...
Good morning.
I pull queries from main frame tables and
use
social
security numbers quite frequently.
Redesigning
the
tables
is unfortunately not an option or I
would do
that.
What I
am needing to do is find dashses in
social
security
numbers and replace them with a null
value. I
would
like
to take a social in the format '000- 00-
000'
and
make
it
look like '000000000'. The best place
for
me
to
do
this
is in a query. How would you suggest I
go
about
this.
Thank you for your help!
Sincerely
Ken
.
.
.
.
.
.