Solved

Select query for DBF table in Excel VBA throwing Type mismatch

Posted on 2011-02-22
4
1,387 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
[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
  • 2
4 Comments
 
LVL 42

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

759 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