I'm calling a stored procedure on a sql server from an access
application. I just need the stored procedure to run I do not need any
data returned from the stored procedure to my Access application but I
do pass parameters from my Access application. What I have works fine
and is attached below. But I have one question. Why do I need this
line of code to execute the stored procedure.
Set rst = qdf.OpenRecordset(dbOpenSnapshot)
Here is the rest of my code:
Sub StoredProcedure()
Dim dbs As DAO.DataBase
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim strConnectString As String
Dim Company As Long
Dim JobNumber As String
Dim Shift As Long
Dim DayWorked As String
Company = GetCompany()
JobNumber = "'" & GetJob() & "'"
Shift = GetShift()
DayWorked = "'" & GetDate() & "'"
Set dbs = CurrentDb
strConnectString = "ODBC" & _
";Database=Viewpoint" & _
";UID=ODBC" & _
";PWD=odbc" & _
";DSN=Viewpoint"
Set qdf = dbs.CreateQueryDef("")
qdf.Connect = strConnectString
qdf.ReturnsRecords = True
qdf.SQL = "dbo.uspTRFile " & Company & "," & JobNumber & "," & Shift &
"," & DayWorked & ""
Set rst = qdf.OpenRecordset(dbOpenSnapshot)
rst.Close
Set rst = Nothing
Set qdf = Nothing
End Sub