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
Solved

Executing a query in Access from VB

Posted on 2014-09-16
5
151 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
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

829 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