?
Solved

Running Apped or Update Access Quesry using VisualBasic

Posted on 2003-03-27
6
Medium Priority
?
185 Views
Last Modified: 2013-11-25
I have 2 queries called 'Query_Append' and 'Query_Update' , these are queies made in MS Acces they are of the type APPEND and UPDATE.  How can i run there queries using VisualBasic 6 code?

Thanks,
0
Comment
Question by:MICS
[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
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:msroberts
ID: 8218449
Have you connected to the database you want to run the queries on?  

0
 
LVL 1

Accepted Solution

by:
hmadhur earned 200 total points
ID: 8218453
Hi
Use the following code to do that. The important thing is that you have to set the Command object's CommandType property to adCmdUnknown. This is the catch.

    Dim objAdoConnection As New ADODB.Connection
    Dim objAdoCommand As New ADODB.Command
   
    objAdoConnection.ConnectionString = "dsn=dsnemp"
    objAdoConnection.Open
   
    objAdoCommand.ActiveConnection = objAdoConnection
    objAdoCommand.CommandType = adCmdUnknown
    objAdoCommand.CommandText = "Query_Append"
    objAdoCommand.Execute

Regards
Madhur
0
 
LVL 1

Expert Comment

by:hmadhur
ID: 8218468
Sorry! forgot to mention. You connect by whatever means you want. Either DSN, which I have used, or by using providers.

Madhur
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:MICS
ID: 8220322
Ok. so i tried the example above by hmadhur. and i get the error msg

"Invalid SQL statment; expected 'DELETE','INSERT','PROCEDURE','SELECT', or 'UPDATE'

any ideas?
0
 

Author Comment

by:MICS
ID: 8220457
Ok. I fond that I was accessing teh wrong database.


0
 

Author Comment

by:MICS
ID: 8220461
Worked Great
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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 …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

752 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