[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

problem with a instr function on microsoft access 2013 vba

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

830 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