Solved

Select query for DBF table in Excel VBA throwing Type mismatch

Posted on 2011-02-22
4
1,383 Views
Last Modified: 2013-11-24
Hi,

the below code is failing on the last line, it is throwing a type mismatch error between the MaintCause field and the 'Disaster' value.
MaintCause is a 50 character field so it shouldn't have a problem with comparing strings.
May it have something to do with the query needing to built special for a DBF?

Any help greatly appreciated!
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + root_directory + module_prefix + "\LINES\MAINT\; Extended Properties=DBASE III;"

c1SQL = "Select * from LnMt.dbf Where Maintcause = 'Disaster'"
rs.Open c1SQL, cn, , , adCmdText

Open in new window

0
Comment
Question by:AssetFX
  • 2
4 Comments
 
LVL 41

Expert Comment

by:pcelba
ID: 34950404
It should not report such error.

You may try VFP OLE DB provider: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e1a87d8f-2d58-491f-a0fa-95a3289c5fd4

Connection string: "Provider=vfpoledb;Data Source=d:\MyDataDirectory\;"

http://www.connectionstrings.com/visual-foxpro

and post more details about the errors.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 34956867
Can you try the  select statement directly in Access to see if you get the same error?
0
 

Accepted Solution

by:
AssetFX earned 0 total points
ID: 34957799
Hi guys, sorry for the delay, in Brisbane and internet is not very stable at the moment.

Feel silly but I just tried recreating the table and it started to work, the table is created as a linked table to a application to MapInfo and I believe it may have been corrupt.

Thanks for advice though
0
 

Author Closing Comment

by:AssetFX
ID: 34990898
Be careful with MapInfo linked attribute tables
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

758 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

14 Experts available now in Live!

Get 1:1 Help Now