473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

filtering out "#Error"

I'm doing a replace function on a phone number field:

Expr1: NZ(ReplaceText([PROV_PHONE]),"")

and it converts most of them but for others I get this "#Error" in the
fields. Since I will need to do a join on this field to another table,
I'm confident Access will spit out an error when/if I do.

I tried handling it with the 'NZ' as you see above and also in the
function itself:

Public Function replaceText(inText As String) As String
On Error GoTo Errer
Dim reText As String

reText = Replace(inText, " ", "")
replaceText = Replace(reText, "-", "")
Exit Function

Errer:
replaceText = ""
End Function

Feb 21 '07 #1
2 3754
Strings cannot be null.
Change the ReplaceText() function so it can accept a variant.
You probably want it to be able to return a null as well.

Public Function replaceText(inText As Variant) As Variant
On Error GoTo ErrHandler

replaceText = Null
If Not IsNull(inText) Then
replaceText = Replace(Replace(inText, " ", ""), "-", "")
End If

ExitHandler:
Exit Function

ErrHandler:
resume ErrHandler
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<ch************@yahoo.comwrote in message
news:11**********************@k78g2000cwa.googlegr oups.com...
I'm doing a replace function on a phone number field:

Expr1: NZ(ReplaceText([PROV_PHONE]),"")

and it converts most of them but for others I get this "#Error" in the
fields. Since I will need to do a join on this field to another table,
I'm confident Access will spit out an error when/if I do.

I tried handling it with the 'NZ' as you see above and also in the
function itself:

Public Function replaceText(inText As String) As String
On Error GoTo Errer
Dim reText As String

reText = Replace(inText, " ", "")
replaceText = Replace(reText, "-", "")
Exit Function

Errer:
replaceText = ""
End Function
Feb 22 '07 #2
Of course, that worked perfectly.

Strange thing though.. I filtered on the result of the replace in the
designer - 'Not Null' and then 'Not 0' and it returned an infinite
record set.
Feb 22 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Aaron G via AccessMonster.com | last post by:
Wanted to share a solution to something which I didn't find on the net: EVERY form in my Microsoft Access 2002 database gave an error any time any code was to be called: form OnOpen, button...
5
by: TJS | last post by:
trying to display pdf file in browser fails on this line: Response.ContentType = "application/pdf" getting an error about no declaration found for "response" what declaration is needed ???
1
by: Dgates | last post by:
This request might belong in a "SQL"-related newsgroup, but it's such a pain using Agent to subscribe to a new group (and download its 50,000 messages!) just to ask one question. So, since it...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
8
by: Ravi Ambros Wallau | last post by:
Hey guys: What can I do when an "Error Creating Control" is displayed on the form (instead of the control), and a tooltip indicating the error never is displayed? Is there some log, some hidden...
1
by: timbobd | last post by:
I have encountered a situation that I don't understand. When I call a sub of Friend scope (in an object with Friend scope), I am getting an error "Public member 'subname' not found in type...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
13
by: hn.ft.pris | last post by:
Hi: I have the following simple program: #include<iostream> using namespace std; int main(int argc, char* argv){ const double L = 1.234; const int T = static_cast<const int>(L); int arr;
5
by: Nathan Sokalski | last post by:
I have an ASP.NET application which is giving the following JavaScript error: 'theForm' is undefined However, when I do a View Source one of the <scriptelements is as follows: <script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.