pass through query with parameter

qwertyjjj

Registered User.
Local time
Today, 14:49
Joined
Aug 8, 2006
Messages
262
I have a pass through query but the stored procedure on SQL server requires a parameter.
How do I pass the parameter in the following code?

At the moment the pass through query just says:
EXEC Sproc @Name

Dim i As Integer
Dim iNumCols As Integer
Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset("Query1")

Application.SetOption "Show Status Bar", True
StatusBar = SysCmd(acSysCmdSetStatus, "Formatting export file... please wait.")

'Start a new workbook in Excel
Dim oApp As New Excel.Application
Dim oBook As Excel.workBook
Dim oSheet As Excel.workSheet

'uncomment these 2 lines for debugging
'oApp.Visible = True
'oApp.UserControl = True

Set oBook = oApp.Workbooks.Add
Set oSheet = oBook.Worksheets(1)

'Add the field names in row 1
iNumCols = rs.Fields.Count
For i = 1 To iNumCols
oSheet.Cells(1, i).Value = rs.Fields(i - 1).Name
Next

'Add the data starting at cell A1
oSheet.Range("A2").CopyFromRecordset rs
 
I do it like this:

Code:
dim qdf as querydef

set qdf = currentdb.querydefs("Query1")

qdf.parameters(1) = whatever

set rs = qdf.openrecordset
 

Users who are viewing this thread

Back
Top Bottom