Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Parameters from Main form to SubForms

Status
Not open for further replies.

tgtfranz

Programmer
Mar 8, 2007
37
US
Problem, I am prompted twice for the same parameters. It makes sense because both sprocs are using the same parameter information but it would be nice to find a way to pass that parameter so the end user does not have to enter it twice.

History:

I have a form that is populated with a stored procedure and it works great. The key fields in here is the empid, beginning period date and ending period date. This is the MAIN form.

Inside of this form, I have a subform that is calling the hours for this employee and the date range that is given. This is also from a stored procedure. This sproc also returns the correct data that is needed. Here is my code for this sproc:


Thanks


CREATE PROCEDURE dbo.sp_PayTypesandHoursSummaryDateRange

@EnterEmpNo int
,@EnterStartingCheckDate datetime
,@EnterEndingCheckDate datetime
AS

SELECT DISTINCT
pc.emp_no
, pcpa.pay_type
, pt.description
, SUM(pcpa.hours) AS Hours
, SUM(pcpa.cmw_gross) AS Gross

FROM
pay_checks AS pc
INNER JOIN
pay_checks_pay_assoc AS pcpa
ON
pc.pay_checks = pcpa.pay_checks
INNER JOIN
dbo.pay_types AS pt
ON
pcpa.pay_type = pt.pay_type

WHERE
pc.emp_no = --@EnterEmpNo
6111
AND
CONVERT(smalldatetime, pc.check_date)
BETWEEN --@EnterStartingCheckDate
'2000-01-01 00:00:00'
AND --@EnterEndingCheckDate
'2000-06-30 00:00:00'

GROUP BY
pc.emp_no
, pcpa.pay_type
, pt.description


 
Hi, I don't know anything about stored procedures but if you can refer to a text box on a form from them then this will work.

create two new text boxes on your form.

promp the user for the parameter details and store them in the 2 text boxes

refer to these text boxes from your sprocs instead of using EnterStartingCheckDate and EnterEndingCheckDate


jimlad

"There's this thing called being so open-minded your brains drop out." -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top