Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Executing a query in Access from VB

Posted on 2014-09-16
5
Medium Priority
?
170 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 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

782 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