Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 September 25th, 2003, 12:56 AM
Registered User
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default DAO Run Time Error 3423 - VB6 to Access2000

Hi all, this is my first post. I am very frustrated with Microsoft Visual Studio 6 - Visual Basic, I am trying to use DAO to talk to a database that was created with Access 2000 and am having no luck. I have the latest service packs for Office and for Visual Basic and Jet and everything like that, but the code still isn't working.

The database file has a system DSN of "lsdata" and I have tried referring to it using both the DSN and the full path.

Basically what I'm trying to do is to open the database using ODBC so that I can change the structure of it using DAO. I was able to get it to work using SQL but I need more control (you can't add autonumber fields using SQL).

Here is the code:
      'First I do this
Dim TheDatabaseThingy as Database
      'And I have tried both of these
Set TheDataBaseThingy = OpenDatabase("lsdata", dbDriverCompleteRequired, False, "ODBC;UID=;PWD=;DSN=lsdata")
Set TheDataBaseThingy = OpenDatabase("C:\Program Files\Microsoft Visual Studio\VB98\Connexions Project\Connexions Databases\50.mdb", False, False, "ODBC;DSN=lsdata")

Both "Set" statements return run time error 3423 which has me greatly puzzled. We have tried exporting it as an earlier version of access, and then we got error 3170.

I am tearing my hair out, any help would be appreciated.

Old September 25th, 2003, 09:31 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

Since you're using a Jet database, why mess around with ODBC at all? Just use the Microsoft Jet workspace that is the default workspace of the DAO OpenDatabase method. The Microsoft Jet database engine will be automatically loaded into memory for you, and you can manipulate any .mdb database in your code:

Private Sub cmdAlterDB_Click()
    Dim dbs As DAO.Database
    Dim tblDef As TableDef
    Dim fldDef As Field

    dbName = "C:\Temp\Northwind.mdb"

    Set dbs = OpenDatabase(dbName)
    ' The above line is an abbreviation of
    ' Set dbs = DBEngine.Workspaces(0).OpenDatabase(dbName)
    ' Your working in a Microsoft Jet workspace environment
    ' here. You'ld only want to use ODBC is you wanted to avoid
    ' loading the Jet database engine.
    Set tdf = dbs.TableDefs("Customers")
    Set fld = tdf.CreateField("CustomerThingy", dbText, 20)
    tdf.Fields.Append fld

    MsgBox ("New field successfully created.")
End Sub



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Printer at run time for crystal rpt, VB6.0 fiiyo ASP.NET 1.0 and 1.1 Basics 0 September 19th, 2006 06:58 AM
RUN-TIME ERRORS IN MY VB6 APPLICATION Nadalik VB How-To 1 June 15th, 2006 11:18 AM
Error 20515 when run CR9 from Vb6 and Access2000 Ann92 VB How-To 0 June 22nd, 2004 08:04 AM
Getting at Access2000 with DAO - big problem Iblys Access VBA 1 September 25th, 2003 01:03 AM
access2000 and vb6.0 cydel VB How-To 1 September 5th, 2003 04:20 AM

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