Solved

Call Store Procedure From Ms Access?

Posted on 2001-09-12
3
280 Views
Last Modified: 2008-03-17
How can I call the store procedure in SQL and return the result back to Ms Access??

In my code, i already using the below method

    Dim tdfOldLink As TableDef
    Dim tdfNewLink As TableDef
    Dim strConnect As String
           
    Set tdfNewLink = CurrentDb.CreateTableDef("Temp")
    tdfNewLink.Connect = "ODBC;"
    tdfNewLink.SourceTableName = "SAMPLE"
    tdfNewLink.Attributes = dbAttachSavePWD
    CurrentDb.TableDefs.Append tdfNewLink
    strConnect = CurrentDb.TableDefs("Temp").Connect
    CurrentDb.TableDefs.Delete "Temp"



Thankx
0
Comment
Question by:Kelvsat
[X]
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
3 Comments
 
LVL 7

Expert Comment

by:Jonathan Kelly
ID: 6478736
to call a stored procedure from sql server using ADO

dim recTheResultSet as New ADODB.Recordset
dim cmdTheStoredProcedure as New ADODB.Command

cmdTheStoredProcedure.CommandText = "spYourStoredProc"
cmdTheStoredProcedure.Type = StoredProcedure
cmdTheStoredProcedure.Connection = CurrentProject.Connection


Set recTheResultSet = cmdTheStoredProcedure.Execute
0
 
LVL 4

Accepted Solution

by:
zuijdhoek earned 100 total points
ID: 6478760
Kelvsat,

I don't understand what the purpose of your code.
You are trying to link a table dynamically and then what?
If you want to run a stored procedure (SQL Server?) using Access you have to create a pass-through query
(Create new query, select form the menubar Query -> Sqlspecific -> Pass-through. Check the properties of the query,  define the connectionstring and make sure records will be returned )

In case you are SQL Server as backend database you can write a SQL-statement somewhat like this

EXEC <YourProcedureName>

In case you want to store the results of this query in a new table you can create another make-table query which invokes the pass-through query.

Hope this might give you some idea.

Mark
0
 

Author Comment

by:Kelvsat
ID: 6489460
I got it. Thanx.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

734 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