Hello,
I have been struggling with this for days. I finally just got the stored procedure to execute through vba and to populate a form in my database's record source property. I started first with just getting it to execute a stored procedure with no parameters because I was having trouble passing them. NOw I know it executes, but I need to understand how to pass the parameters.
Ultimate I want to pass in a number, then 2 dates. So it would be exec sp_GetAMIWorklist 1, '07/01/2012','09/30/2012' if i just execute straight from SSMS. I just don't understand how to know when I put the right quotes and how to concatenate it all together. Does anyone have any good refrences?
Here is my code: (I made the line red where I have trouble)
Private Sub Form_Load()
Dim db As DAO.Database
Dim rstAMIWorklist As DAO.Recordset
' Set database variable to current database.
Set db = CurrentDb
' Open QueryDef object.
Set qdf = db.QueryDefs("sp_GetAMIWorklist")
'HERE IS MY PROBLEM LINE
qdf.SQL = "EXEC sp_GetAMIWorklist " & Forms!frmNewMainMenuSelections!cboFacility & "" & '"& Forms!frmNewMainMenuSelections!txtStartDate & "" &
& Forms!frmNewMainMenuSelections!txtEndDate & ""
qdf.ReturnsRecords = True
'Open Recordset object.
Set rstAMIWorklist = qdf.OpenRecordset()
rstAMIWorklist.MoveFirst
Set Me.Recordset = rstAMIWorklist
I have been struggling with this for days. I finally just got the stored procedure to execute through vba and to populate a form in my database's record source property. I started first with just getting it to execute a stored procedure with no parameters because I was having trouble passing them. NOw I know it executes, but I need to understand how to pass the parameters.
Ultimate I want to pass in a number, then 2 dates. So it would be exec sp_GetAMIWorklist 1, '07/01/2012','09/30/2012' if i just execute straight from SSMS. I just don't understand how to know when I put the right quotes and how to concatenate it all together. Does anyone have any good refrences?
Here is my code: (I made the line red where I have trouble)
Private Sub Form_Load()
Dim db As DAO.Database
Dim rstAMIWorklist As DAO.Recordset
' Set database variable to current database.
Set db = CurrentDb
' Open QueryDef object.
Set qdf = db.QueryDefs("sp_GetAMIWorklist")
'HERE IS MY PROBLEM LINE
qdf.SQL = "EXEC sp_GetAMIWorklist " & Forms!frmNewMainMenuSelections!cboFacility & "" & '"& Forms!frmNewMainMenuSelections!txtStartDate & "" &
& Forms!frmNewMainMenuSelections!txtEndDate & ""
qdf.ReturnsRecords = True
'Open Recordset object.
Set rstAMIWorklist = qdf.OpenRecordset()
rstAMIWorklist.MoveFirst
Set Me.Recordset = rstAMIWorklist