Solved

Application Object Error 5017

Posted on 2007-03-30
21
484 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

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