If you still wanted to keep this form a normal “bound” access form then you could do something like this.
Setup a pass through query that fires your SP. The basic format for that is along the lines of this
EXEC [dbo].[spAgents_with_more_than_X_days_sick_by_Team] @Date_from = N'2009-09-14', @Date_to = N'2010-09-14', @Team_ID = N'TEM1', @Days_sick =5
You would then modify this when opening the form like this
Set qDef = DBEngine(0)(0).QueryDefs("RqryAgents_more_than_X_sicks_detail_2")
With qDef
.Connect = strSQL_con_string
.SQL = "EXEC [dbo].[spAgents_with_more_than_X_days_sick_by_Team]"
.SQL = .SQL & " @Date_from = N'" & Format(Me.txtDate_from, "yyyy-mm-dd") & "', "
.SQL = .SQL & "@Date_to = N'" & Format(Me.txtDate_to, "yyyy-mm-dd") & "', "
.SQL = .SQL & "@Team_ID = N'" & Me.txtTeam_ID & "', "
.SQL = .SQL & "@Days_sick =" & Me.txtDays_sick
End With
This should work just fine however if it was me (and I know it’s not everyone’s preference) but I would make this an unbound form and populate it by firing your SP using ADO to fill a recordset and go from there.
If you want details of how to do that then just ask and I will post an example
EDIT: Code sample added
Dim cmd as new ADODB.Command
Dim dbCon as new ADODB.Connection
Dim rst as new ADODB.Recordset
dbCon.ConnectionString=”Your_Connection_string”
dbCon.open
With cmd
.ActiveConnection = dbCon
.CommandText = "spYour SP"
.CommandType = adCmdStoredProc
.NamedParameters = True
.Parameters.Append .CreateParameter("@Your_pram1", adVarChar, adParamInput, 20, Format(Me.txtDate, "yyyy-mm-dd"))
.Parameters.Append .CreateParameter("@Your_pram2", adSmallInt, adParamInput, 0, Me.cboPhone_skill)
End With
Set rst = cmd.Execute()
With rst
If .EOF=False then
Me.txtYour_text_box_1=!Your_SP_field_1
Me.txtYour_text_box_2=!Your_SP_field_3
Me.txtYour_text_box_3=!Your_SP_field_2
End if
End with
Rst.close
Dbcon.close
Set rst=nothing
Set cmd=nothing
Set dbcon=nothing