Solved

Executing a query in Access from VB

Posted on 2014-09-16
5
139 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
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
pdebaets earned 500 total points
Comment Utility
docmd.openquery "Append_OTC"
0
 

Author Comment

by:morinia
Comment Utility
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
Comment Utility
What line of code is highlighted when you get the compile error?
0
 
LVL 16

Expert Comment

by:Sheils
Comment Utility
To execute an append query you can use

Currentdb.Execute "Append_OTC" , dbFailOnError
0
 
LVL 16

Expert Comment

by:Sheils
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

772 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

10 Experts available now in Live!

Get 1:1 Help Now