Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i make my VB code run an Access Query when VB opens the file 2

Status
Not open for further replies.

JoaquimM

Programmer
May 19, 2003
9
US
Hi
I'm trying to make a query i have in Access run when I open the file through VB. The query will run if I open the Access file using Access but when my VB code opens the file it won't run. Anyone know how I can force the query to run? Thanks
 
You should be able to use ADO to execute the access query. I don't have the syntax at hand, but a little searching should give you the answer.

Thanks and Good Luck!

zemp
 
One thing you can do is for your SQL statement, use the following syntax:
Code:
SQLStmt = &quot;{CALL <queryname> (<param1>, <param2>,...) }&quot;
Note that the query parameter list is enclosed in parenthesis, and the entire statement is enclosed in curley braces. Then open the recordset just as you would with any other SQL statement.
RecSet.Open SQLStmt, ADO_Connect


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
It is worth a purple, even for the concept. I assume that in the broader process the AD_Connect refers to refers to an ADO.Connection object which 'point to&quot; the Ms. A. &quot;.MDB&quot; application?



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Yes, ADO_Connect is the Connection Object

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
JET 4 supports ANSI 92 Extensions so you can use the EXECUTE clause for stored proceedures in the below syntax:
(SomeProceedure is a query with one parameter as criteria)

Conn.Execute &quot;EXECUTE SomeProceedure 'abc'&quot;
or
Set rsADO = conn.Execute (&quot;EXECUTE SomeProceedure 'abc'&quot;)

or
rsADO.Open (&quot;EXECUTE SomeProceedure 'abc'&quot;)

JET 4 also supports:

CREATE PROCEDURE
CREATE VIEW
DROP PROCEDURE
DROP VIEW

CREATE PROC[EDURE] procedure [(param1 datatype1 [, param2 datatype2 [, ...] ])] AS sql-statement;

EXEC[UTE] procedure [param1 [, param2 [, ...] ]] ;

DROP PROC[EDURE] procedure;

CREATE VIEW view [(field1 [, field2 [,...] ])] AS select-statement;

DROP VIEW view;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top