Solved

problem with a instr function on microsoft access 2013 vba

Posted on 2014-04-29
3
1,276 Views
Last Modified: 2014-04-30
hi

i have a code like this
    
Set TDS = db.TableDefs
On Error GoTo Err_Proc
'Loop through the tables collection
    For Each td In TDS
        If td.Connect = ";DATABASE=" & OldPathName Then
            msgbox "find Table"
        end if

Open in new window

this code is working just fine, but when  i tried a similar code that contain a instr function i get an error 13-type mismatch

this the not working code
 If td.Connect = InStr(1, td.Connect, """ & OldPathName & """) <> 0 Then

Open in new window


how can i fix this code to be able to use instr
thanks
0
Comment
Question by:bill201
[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
3 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 500 total points
ID: 40031296
InStr returns a number so you can't compare it to a string, which is what I assume td.Connect returns.

To check if OldPathName is in td.Connect check if InStr returns a  value more than 0.
If InStr(td.Connect,  OldPathName) <> 0 Then 

Open in new window

0
 
LVL 10

Expert Comment

by:ukerandi
ID: 40031303
Try to use  Cint( instr
0
 

Author Comment

by:bill201
ID: 40031445
ukerandi Thank you too, but it did not solve the problem, But thanks to the desire
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 custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

740 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