Solved

Application Object Error 5017

Posted on 2007-03-30
21
455 Views
Last Modified: 2008-01-09
Hi all, hope all is well.

Question: Got two button on a form to validate the data entered. The first button works like a charm. Why do i get an Error 5017: Application-defined or object-defined error? on the second button (command8)

Private Sub Command6_Click()
Dim regularexpressionobject As Object
Set regularexpressionobject = New VBScript_RegExp_10.RegExp

With regularexpressionobject
 .Pattern = "^(([a-zA-Z0-9\.\-_\&]+)([a-zA-Z0-9]+)@([a-zA-Z0-9\-]+)(\.[a-zA-Z0-9\-]+){1,6})$"
 .IgnoreCase = True
 .Global = True
End With

If regularexpressionobject.Test(EmailAddress.Value) Then
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
End Sub

Private Sub Command8_Click()
Dim regularexpressionobject As Object
Set regularexpressionobject = New VBScript_RegExp_10.RegExp

With regularexpressionobject
 .Pattern = "(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
 .IgnoreCase = True
 .Global = True
End With

If regularexpressionobject.Test(StreetAddress.Value) Then
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
End Sub
 
Thanks
Sean
0
Comment
Question by:SeanNij
  • 11
  • 9
21 Comments
 
LVL 38

Expert Comment

by:Jim P.
Comment Utility
I would check references.

Ctrl+G then Tools --> References. See if any are marked missing.
0
 
LVL 1

Author Comment

by:SeanNij
Comment Utility
Nope nothing missing. Keep in mind - both buttons are on the same form. Press the first one and it works - press the second one and i get that error?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
try releasing the object variable  { regularexpressionobject } after you use it

set regularexpressionobject=nothing
0
 
LVL 1

Author Comment

by:SeanNij
Comment Utility
Nope no luck.

Could it be something to do with the pattern - may an incorrect pattern stuff it up?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility

try this

Private Sub Command6_Click()
Dim regularexpressionobject As Object
     'Set regularexpressionobject = New VBScript_RegExp_10.RegExp
Set regularexpressionobject = CreateObject("VBScript.RegExp")

With regularexpressionobject
 .Pattern = "^(([a-zA-Z0-9\.\-_\&]+)([a-zA-Z0-9]+)@([a-zA-Z0-9\-]+)(\.[a-zA-Z0-9\-]+){1,6})$"
 .IgnoreCase = True
 .Global = True
End With

If regularexpressionobject.Test(EmailAddress.Value) Then
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
Set regularexpressionobject = Nothing

End Sub

Private Sub Command8_Click()
Dim regularexpressionobject As Object
         'Set regularexpressionobject = New VBScript_RegExp_10.RegExp
Set regularexpressionobject = CreateObject("VBScript.RegExp")

With regularexpressionobject
 .Pattern = "(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
 .IgnoreCase = True
 .Global = True
End With

If regularexpressionobject.Test(StreetAddress.Value) Then
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
Set regularexpressionobject = Nothing

End Sub
 

0
 
LVL 1

Author Comment

by:SeanNij
Comment Utility
Exactly same error msg.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
btw, which line is higlighted?
0
 
LVL 1

Author Comment

by:SeanNij
Comment Utility
If regularexpressionobject.Test(StreetAddress.Value) Then

if i copy the pattern from the first button into the second set of code it works - can it be the pattern itself?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
remove the .value

If regularexpressionobject.Test(StreetAddress) Then

how do you pass the StreetAddress?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
SeanNij,
it is the pattern that is giving you the error.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
try using this pattern

  .Pattern = "^([a-zA-Z0-9\.\-_\&])([a-zA-Z0-9]+)"


Private Sub Command8_Click()
Dim regularexpressionobject As Object
         'Set regularexpressionobject = New VBScript_RegExp_10.RegExp
Set regularexpressionobject = CreateObject("VBScript.RegExp")

With regularexpressionobject
' .Pattern = "(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
 
 .Pattern = "^([a-zA-Z0-9\.\-_\&])([a-zA-Z0-9]+)"

 .IgnoreCase = True
 .Global = True
End With

If regularexpressionobject.Test(StreetAddress.Value) Then
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
Set regularexpressionobject = Nothing

End Sub
 
0
 
LVL 1

Author Comment

by:SeanNij
Comment Utility
then it works.

however not allowing / disallowing what i need - so therefor the pattern line is wrong.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
SeanNij,
<so therefor the pattern line is wrong.>
wish i could see from the crystal ball what  pattern you need
i can not guess what you need to filter,
0
 
LVL 1

Author Comment

by:SeanNij
Comment Utility
and here i thought you would be able too...;)

I want to check that address lines may contain the phrase PO BOX/PRIVATE BAG/POST or any abbreviation there off.

Question: Do you ever sleep?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
I just woke up.

sean,
can you post some real data, of different variation.
0
 
LVL 1

Author Comment

by:SeanNij
Comment Utility
CompanyName,StreetAddress,PostalAddress,City
Tarsus Networking (Pty) Ltd.,Prosperity Park Democracy Way Milnerton 7441,PO Box 19234,Vlaeberg
Bromor Foods (Pty) LTD,No 5 Sunrise Circle Ndabeni,PO Box 28,Cape Town
Trencor Ltd,PO Box 13160 Dowerglen Ext 7,1313 Main Tower, Heerengracht Street Standard Bank Centre, CT
USABCO,,PO Box 277,Bellville Boland Bank,333 Main Road Paarl",PO Box 4,Paarl
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility

this

 .Pattern = "^([a-zA-Z0-9\.\-_\&amp;()])([a-zA-Z0-9]+)"

pass the the top three sample, the last one failed due to the  " in { Main Road  Paarl",PO Box 4,Paarl }  which i think is a wrong format

0
 
LVL 1

Author Comment

by:SeanNij
Comment Utility
But its this pattern i'm trying to get too work:

"(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
try this

.Pattern ="(i?)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
0
 
LVL 1

Author Comment

by:SeanNij
Comment Utility
YIPPEEEEE

what is the diff between ?i and i?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
?    -- Matches 0 or 1 instances of preceding character
--------------------------------------------^^^^^^
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now