INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Vba questions

How do I execute a SQL Server Stored Procedure from Access? by jmeadows7
Posted: 1 Oct 02

Use the following code to call a stored procedure - the example takes two parameters from my form:
The strConnect is a constant in the form of:
"ODBC;DSN=YOUR_DSN_NAME;SRVR=YOUR_SERVER_NAME;DATABASE=YOUR_DB_NAME;UID=youruserid;PWD=youruseridpassword;"

  Dim strConnect As String
    Dim strSQL As String
    Dim dbs As Database
    Dim qdf As QueryDef
    Dim strErrMsg As String

           Set dbs = CurrentDb
            
            strConnect = c_CONN_STR
                         
            Set qdf = dbs.CreateQueryDef("")
            qdf.Connect = strConnect
            strSQL = "exec cssp030_Completed_Daily_Updates " & Me![txtsw010_Loc_Id] & ",'" & Me![txtsw010_Retrieve_Date] & "', " & "'" & Forms![frm000_Main]![txtW000_User_ID] & "'"
            qdf.ReturnsRecords = False
            qdf.SQL = strSQL
            dbs.QueryTimeout = 2000 'Set timeout to 4 minutes so it doesn't timeout.
            qdf.ODBCTimeout = 1000
            qdf.Execute
            DoCmd.Hourglass False

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close