I just converted my mdb to adp, I use a form that consists of checkboxes to determine which employees' reports print. When the user chooses the employees and click "Print Reports", a series of message boxes appear asking for a begin date and an end date. My question is, what would be the easiest way to get my report to work as it did before I converted it to adp? I tried creating the stored procedure:
ALTER PROCEDURE dbo.PhoneLogRptSp
@begin_date datetime,
@end_date datetime,
@who nvarchar(25)
AS SELECT dbo.PHONECALL.callerAcctNum, dbo.PHONECALL.callDate, dbo.PHONECALL.callTime, dbo.PHONECALL.callerLName, dbo.PHONECALL.callerFName,
dbo.PHONECALL.callerAddress, dbo.PHONECALL.CALLERCITY, dbo.PHONECALL.callerState, dbo.PHONECALL.callerZip,
dbo.PHONECALL.callerHomePh, dbo.PHONECALL.callerWorkPh, dbo.PHONECALL.callerCompany, dbo.PHONECALL.callReason,
dbo.PHONECALL.OPID, dbo.Employees.empName
FROM dbo.PHONECALL INNER JOIN
dbo.Call_Employee_Link ON dbo.PHONECALL.callID = dbo.Call_Employee_Link.callID INNER JOIN
dbo.Employees ON dbo.Call_Employee_Link.empName = dbo.Employees.empName
WHERE (dbo.PHONECALL.callDate BETWEEN @begin_date AND @end_date) AND (dbo.Employees.empName LIKE @who)
This works if I disregard my form with the checkboxes and just enter the begin date, end date and who manually, but I have to enter all the data for each employee seperately.
I tried passing in perameters via code but it doesn't seem to work:
Dim begin_date As Date
Dim end_date As Date
Dim who As String
begin_date = Format(InputBox("Enter beginning date of log to print (mm/dd/yyyy).", "Begin Report Date", DATE), "medium date")
end_date = Format(InputBox("Enter ending date of log to print (mm/dd/yyyy).", "Begin Report Date", DATE), "medium date")
who = "some_employee"
Dim db As Database, rst As ADODB.Recordset
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim param1 As ADODB.Parameter, param2 As ADODB.Parameter, param3 As ADODB.Parameter
' Connect
Set cnn = CurrentProject.Connection
Set cmd.ActiveConnection = cnn
' Set up a command object for the stored procedure.
cmd.CommandText = "PhoneLogRptSp"
cmd.CommandType = adCmdStoredProc
Set param1 = cmd.CreateParameter("@begin_date", adDBDate, adParamInput)
cmd.Parameters.Append param1
param1.Value = begin_date
Set param2 = cmd.CreateParameter("@end_date", adDBDate, adParamInput)
cmd.Parameters.Append param2
param2.Value = end_date
Set param3 = cmd.CreateParameter("@who", adVarChar, adParamInput, 25)
cmd.Parameters.Append param3
param3.Value = who
' Execute command to run stored procedure
cmd.Execute
DoCmd.OpenReport reportname:="Phone Log Report", view:=acViewPreview
I know this still doesn't utilize the checkbox form, but once I get this working I can then easily put the results of the checkboxes into the variables.
ALTER PROCEDURE dbo.PhoneLogRptSp
@begin_date datetime,
@end_date datetime,
@who nvarchar(25)
AS SELECT dbo.PHONECALL.callerAcctNum, dbo.PHONECALL.callDate, dbo.PHONECALL.callTime, dbo.PHONECALL.callerLName, dbo.PHONECALL.callerFName,
dbo.PHONECALL.callerAddress, dbo.PHONECALL.CALLERCITY, dbo.PHONECALL.callerState, dbo.PHONECALL.callerZip,
dbo.PHONECALL.callerHomePh, dbo.PHONECALL.callerWorkPh, dbo.PHONECALL.callerCompany, dbo.PHONECALL.callReason,
dbo.PHONECALL.OPID, dbo.Employees.empName
FROM dbo.PHONECALL INNER JOIN
dbo.Call_Employee_Link ON dbo.PHONECALL.callID = dbo.Call_Employee_Link.callID INNER JOIN
dbo.Employees ON dbo.Call_Employee_Link.empName = dbo.Employees.empName
WHERE (dbo.PHONECALL.callDate BETWEEN @begin_date AND @end_date) AND (dbo.Employees.empName LIKE @who)
This works if I disregard my form with the checkboxes and just enter the begin date, end date and who manually, but I have to enter all the data for each employee seperately.
I tried passing in perameters via code but it doesn't seem to work:
Dim begin_date As Date
Dim end_date As Date
Dim who As String
begin_date = Format(InputBox("Enter beginning date of log to print (mm/dd/yyyy).", "Begin Report Date", DATE), "medium date")
end_date = Format(InputBox("Enter ending date of log to print (mm/dd/yyyy).", "Begin Report Date", DATE), "medium date")
who = "some_employee"
Dim db As Database, rst As ADODB.Recordset
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim param1 As ADODB.Parameter, param2 As ADODB.Parameter, param3 As ADODB.Parameter
' Connect
Set cnn = CurrentProject.Connection
Set cmd.ActiveConnection = cnn
' Set up a command object for the stored procedure.
cmd.CommandText = "PhoneLogRptSp"
cmd.CommandType = adCmdStoredProc
Set param1 = cmd.CreateParameter("@begin_date", adDBDate, adParamInput)
cmd.Parameters.Append param1
param1.Value = begin_date
Set param2 = cmd.CreateParameter("@end_date", adDBDate, adParamInput)
cmd.Parameters.Append param2
param2.Value = end_date
Set param3 = cmd.CreateParameter("@who", adVarChar, adParamInput, 25)
cmd.Parameters.Append param3
param3.Value = who
' Execute command to run stored procedure
cmd.Execute
DoCmd.OpenReport reportname:="Phone Log Report", view:=acViewPreview
I know this still doesn't utilize the checkbox form, but once I get this working I can then easily put the results of the checkboxes into the variables.