Solved

problem with a instr function on microsoft access 2013 vba

Posted on 2014-04-29
3
1,287 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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 …

707 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