?
Solved

Application Object Error 5017

Posted on 2007-03-30
21
Medium Priority
?
516 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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 2000 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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 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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

771 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