Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 15th, 2005, 09:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default Reading DBF Files

I have this code that works when the input file is NOT a dBase III input file, i.e. an MDB. When it is a DBF, however, I'm getting an error message that the path and file do not exist even though it does. Any clues why it won't work? Here's the code snippet. It fails at the first cn.Open statement.

Code:
Public Function strShowUsers(strMDB as String) As String

    Dim cn As New ADODB.Connection, rs As New ADODB.Recordset

    If UCase(Right(strMDB, 3)) = "DBF" Then
        cn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & strMDB & "; Extended Properties = DBASE III;"
    Else
        cn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & strMDB
    End If

    Set rs = cn.OpenSchema(adSchemaProviderSpecific, , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

Thanks in advance.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old April 15th, 2005, 02:18 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Greg,

I would initially suspect that the access permissions to DBFs are different than the other files you are testing against.

Make sure that the process running the code you show here has the nec. access rights to accomplish the opening of the file.

(You could verify this with an attempt to outright open the file with FreeFile and Open, etc.)
 
Old April 18th, 2005, 02:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Brian,

The access permissions are the same. Any other ideas?


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old April 18th, 2005, 02:50 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Did you try opening the file outright using VB's file manipulation methods?
What was the result?
 
Old April 18th, 2005, 02:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

What exactly did you have in mind when you say "VB's file manipulation methods"? Did you have any particular function or call in mind?


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old May 11th, 2005, 07:33 PM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had this error also.
What I did is to use filename in 8.3 Dos format
Which basically says
thiif your table is called:

ThisIsMyTable.DBF

You must use:

ThisIs~1.DBF

as the filename






Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading large files ravichandrae Pro Java 1 January 11th, 2008 04:42 AM
Reading from Excel Files interrupt Javascript How-To 8 September 28th, 2006 09:31 AM
Reading .ini files anisurr C++ Programming 2 February 7th, 2006 05:02 PM
Reading excel files dotnetprogrammer VS.NET 2002/2003 1 June 29th, 2005 07:01 AM
reading files nightsurfer JSP Basics 0 August 10th, 2003 04:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.