Solved

Getting Office Automation to work within VB6

Posted on 2010-09-01
4
430 Views
Last Modified: 2012-05-10
I have a VB application the uses data from a MSAccess DB.  I have this code that works correctly.

        Set acApp = CreateObject("Access.Application")
            With acApp
                .OpenCurrentDatabase "V:\FRED\UPS_VInfo\UPS_VInfoVB.mdb"
                .DoCmd.TransferText , "UPS_Import_Raw", "UPSImport", _
                        mPathImport & mFile1, False
                .CloseCurrentDatabase
                .Quit
            End With
        Set acApp = Nothing

When I change the DoCmd.OpenQuery "qryName" the code fails with something about Office Automation failing.  The "qryName" is a simple update query.  Is there anyway to get this sort of query to work from within VB?

Appreciate assistance.
Fred
0
Comment
Question by:Tylendal1
4 Comments
 
LVL 9

Expert Comment

by:javajws
ID: 33583361
Have you tried using
CurrentDb.Execute <Query Name>, dbFailOnError
instead of the openquery command?

I'm guessing that you are not turning off the error messages, etc.

See:
http://www.utteraccess.com/forum/Openquery-runSQL-t1832567.html
0
 

Accepted Solution

by:
Tylendal1 earned 0 total points
ID: 33641154
Not sure what the issue was but I converted the query to a SQL statement and use db.Execute mSQL and it worked just fine. The query I was attempting to run was an append query and was being lazy hoping the with acApp would work.  I'm sure there is additional syntax that could have been added that would have let it work.
Maybe someone can assist with what the issue is with the acApp code I show.
Fred
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34941433
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

765 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