Solved

Executing a query in Access from VB

Posted on 2014-09-16
5
155 Views
Last Modified: 2014-09-17
Experts,

I have a command "Append_OTC".  What is the syntax to execute this command from VB?
0
Comment
Question by:morinia
[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
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
pdebaets earned 500 total points
ID: 40326321
docmd.openquery "Append_OTC"
0
 

Author Comment

by:morinia
ID: 40326349
I am sorry I did not mention the query is creating a table.  I get this error

Compile error:  argument not Optional

SELECT * INTO ALL_CLAIMS
FROM ALL_HCS_CLAIM
WHERE CLAIM_STATUS IN ('VHPA', 'VCB2')
ORDER BY SALV_OPERATOR;
0
 
LVL 12

Expert Comment

by:pdebaets
ID: 40326368
What line of code is highlighted when you get the compile error?
0
 
LVL 16

Expert Comment

by:Sheils
ID: 40326378
To execute an append query you can use

Currentdb.Execute "Append_OTC" , dbFailOnError
0
 
LVL 16

Expert Comment

by:Sheils
ID: 40326389
You can also pass the sql

Dim strSQL as string

strSQL="SELECT * INTO ALL_CLAIMS FROM ALL_HCS_CLAIM WHERE CLAIM_STATUS IN ('VHPA', 'VCB2') ORDER BY SALV_OPERATOR"

Currentdb.Execute strSQL , dbFailOnError
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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

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