Solved

Select query for DBF table in Excel VBA throwing Type mismatch

Posted on 2011-02-22
4
1,385 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
modify formula same cell multiple times 15 28
MS excel check if Links exist 5 35
Extract Unique List when in Two Columns in Excel 20 26
Msgbox tickler 8 18
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

813 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

12 Experts available now in Live!

Get 1:1 Help Now