[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

problem with a instr function on microsoft access 2013 vba

Posted on 2014-04-29
3
Medium Priority
?
1,308 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 35

Accepted Solution

by:
Norie earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

649 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