Solved

Executing a query in Access from VB

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

773 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