Error #510, then error #1004

Posted on 2008-11-05
Last Modified: 2013-12-25
I have an application that works perfectly on hundreds of PCs running XP or Vista.  We installed on a client;s computer with Vista Business and Micrsoft Office 2007 installed.  Now, when my app gets to a point in the code where it creates a recordset (using DAO) it crashes,  First I get error #510, then click OK, then get error #1004.

The line of code is something like:
sql = "select * from table1 where id = 6"
set rs = db.openrecordset(sql,dbopendynaset)

The strange thing is, it seems that the where clause is what it doesn't like.  Without the where clause I don;t get an error.  For example, if I write:

set rs=db.openrecordset("table1",dbopenrecordset)

I don't get an error.

I've tried changing the DAO360.DLL file to different versions, but that doesn't seem to solve the problem.

Any ideas?
Question by:murray44
    LVL 44

    Expert Comment

    I suspect there are more errors below the surface.  
    Enable error trapping (On Error Resume Next), check for Err <> 0, and then look at the ERRORS collection.

    Also, I suspect that you will need to prefix the data types of your database objects with "DAO."
    Dim db As DAO.Database
    Dim rs As DAO.Recordset

    Author Comment

    We have declared the variables as you suggest

    If we put "on error resume next", it will skip over any errors which might occur!
    LVL 44

    Expert Comment

    it traps the errors, allowing you to delve deeper into the potential causes such as examining the ERRORS collection.

    Author Comment

    Hmmm, sorry to sound dumb here, but I'm not that familiar with the .NET environment.  I;m more of a VB6 guy still, unfortunately.

    But I did do a small program with VB.NET to try to reproduce the error.  So I could ty out your suggestion there, if I knew how to access this errors collection of which you speak.

    I don;t know if I mentioned this, but this error is hard to recreate - it occurs only on a particular client's machine, who;s running Vista Business ed., with Office 2007 and a few other programs installed.

    Thanks for your help on this
    LVL 44

    Expert Comment

    None of my comments relates to the VB.Net environment.  I'm strictly commenting in the VB/VBA perspective on this question.

    Accepted Solution

    I found a solution, thanks.

    It appears the msjet40.dll file was out of sybch on the target machine.  I replaced it and registered it and that solved it.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    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

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    737 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

    22 Experts available now in Live!

    Get 1:1 Help Now