Solved

Application Object Error 5017

Posted on 2007-03-30
21
486 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 9
21 Comments
 
LVL 38

Expert Comment

by:Jim P.
ID: 18823566
I would check references.

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

Author Comment

by:SeanNij
ID: 18823650
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18823709
try releasing the object variable  { regularexpressionobject } after you use it

set regularexpressionobject=nothing
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 1

Author Comment

by:SeanNij
ID: 18823833
Nope no luck.

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

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18824158

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
ID: 18824485
Exactly same error msg.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18824529
btw, which line is higlighted?
0
 
LVL 1

Author Comment

by:SeanNij
ID: 18824999
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18825214
remove the .value

If regularexpressionobject.Test(StreetAddress) Then

how do you pass the StreetAddress?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18825319
SeanNij,
it is the pattern that is giving you the error.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18825495
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
ID: 18827577
then it works.

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

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18827802
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
ID: 18827878
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18828489
I just woke up.

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

Author Comment

by:SeanNij
ID: 18828737
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18828790

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
ID: 18831111
But its this pattern i'm trying to get too work:

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

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 18836211
try this

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

Author Comment

by:SeanNij
ID: 18836403
YIPPEEEEE

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

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18836428
?    -- Matches 0 or 1 instances of preceding character
--------------------------------------------^^^^^^
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

734 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