Hello experts,

I have created a stored procedure on a SQL server that requires a parameter. By simply using a pass-through query in Access I am able to call the stored procedure and provide the variable successfully. I am trying to use VBA to allow for a drop-down box on a form to be sent to the server as the variable. This is what I have so far.

Sub PassThrough()
Dim dbs As DAO.Database
Dim qdfPassThrough As DAO.QueryDef
Dim strSQL As String

Set dbs = CurrentDb()

strSQL = "Exec up_qry_AFE @AFECode = '%" & Form_frm_AFE_Report.ChooseAFE & "'"

Set qdfPassThrough = dbs.CreateQueryDef("passthroughvariable", strSQL)

qdfPassThrough.Connect = "ODBC;DSN=Enertia Reporting;Trusted_Connection=Yes;DATABASE=Gatherin gRpt;Network=DBMSSOCN"
qdfPassThrough.ReturnsRecords = True

DoCmd.OpenQuery ("passthroughvariable")
End Sub



When run, absolutely nothing happens - no errors, no data, no change in the query.

I imagine it is a small error since I am new to VBA.

Thank you for your help.