Solved

problem with a instr function on microsoft access 2013 vba

Posted on 2014-04-29
3
1,242 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
3 Comments
 
LVL 33

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now