troubleshooting Question

Search URL for string causing #Error

Avatar of Travidia
Travidia asked on
Microsoft Access
15 Comments1 Solution211 ViewsLast Modified:
I have an expression that works most of the time.  I need to fix this so it always works.  
This expression captures the AdID from a URL that is entered.  It currently captured this based on the presence of 'ad.asp?a=' or 'adid='.  

What is happening is when users enter a URL that doesn't have an AdID the expression returns: #Error instead of the numeric AdID.  So I want to make it so 0 is returned if there is no AdID.  

Expression:
IIf((Mid(URL,(InStr(10,URL,"http://")+8),12))="at.adexpedia",CLng(Mid(URL,(InStr(10,URL,"ad.asp?a=")+9),7)),IIf((Mid(URL,(InStr(10,URL,"http://")+8),13))="at3.adexpedia",CLng(Mid(URL,(InStr(10,URL,"ad.asp?a=")+9),7)),CLng(Mid(URL,(InStr(10,URL,"adid=")+5),7))))

I tried to use IsNumeric, but this still returned #Error.  Please let me know how this can be done.
ASKER CERTIFIED SOLUTION
GRayL

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros