Tupacmoche
Registered User.
- Local time
- Today, 10:16
- Joined
- Apr 28, 2008
- Messages
- 291
Hi Form Masters,
I developed a stored procedure that will populate an SQL 2008 R2 table based on the parameters selected in an Access form. I'm not sure how to implement the passing and call to the sproc. Simple put the form collects the pledge amt, the number of payments, when the payments start, and finally the frequency (year, bi-yearly,monthly). It then creates the payment schedule. Here is my code any help is appreciated.
DECLARE @TxtHowMuch asint,
@TxtHowMany asint,
@TxtPledgeStartDt asdatetime,
@TxtFrequency asnvarchar(50),-- Yearly, Monthly, Qurterly
@PaymentNumber asint,
@GID asint,
@cnt INT= 0 --Constant
--These values will be brought in from Access
SET @TxtHowMuch = 100000
SET @TxtHowMany = 10
SET @TxtPledgeStartDt ='2018-01-01'
SET @TxtFrequency ='Yearly'
SET @PaymentNumber = 1
SET @GID = 1
While @cnt < @TxtHowMany
BEGIN
INSERTINTO [dbo].[tblPledgePayments]
(PP_schedule, GiftID, PP_DueDate, PP_Amount)
Select
@PaymentNumber, @GID,
Case
WHEN @TxtFrequency ='Yearly'THENDateAdd(YEAR, @cnt, @TxtPledgeStartDt)
WHEN @TxtFrequency ='Monthly'THENDateAdd(MONTH, @cnt, @TxtPledgeStartDt)
WHEN @TxtFrequency ='Quarterly'THENDateAdd(QUARTER, @cnt, @TxtPledgeStartDt)
END
,@TxtHowMuch / @TxtHowMany
SET @cnt = @cnt + 1;
SET @PaymentNumber = @PaymentNumber + 1;
END;
I developed a stored procedure that will populate an SQL 2008 R2 table based on the parameters selected in an Access form. I'm not sure how to implement the passing and call to the sproc. Simple put the form collects the pledge amt, the number of payments, when the payments start, and finally the frequency (year, bi-yearly,monthly). It then creates the payment schedule. Here is my code any help is appreciated.

DECLARE @TxtHowMuch asint,
@TxtHowMany asint,
@TxtPledgeStartDt asdatetime,
@TxtFrequency asnvarchar(50),-- Yearly, Monthly, Qurterly
@PaymentNumber asint,
@GID asint,
@cnt INT= 0 --Constant
--These values will be brought in from Access
SET @TxtHowMuch = 100000
SET @TxtHowMany = 10
SET @TxtPledgeStartDt ='2018-01-01'
SET @TxtFrequency ='Yearly'
SET @PaymentNumber = 1
SET @GID = 1
While @cnt < @TxtHowMany
BEGIN
INSERTINTO [dbo].[tblPledgePayments]
(PP_schedule, GiftID, PP_DueDate, PP_Amount)
Select
@PaymentNumber, @GID,
Case
WHEN @TxtFrequency ='Yearly'THENDateAdd(YEAR, @cnt, @TxtPledgeStartDt)
WHEN @TxtFrequency ='Monthly'THENDateAdd(MONTH, @cnt, @TxtPledgeStartDt)
WHEN @TxtFrequency ='Quarterly'THENDateAdd(QUARTER, @cnt, @TxtPledgeStartDt)
END
,@TxtHowMuch / @TxtHowMany
SET @cnt = @cnt + 1;
SET @PaymentNumber = @PaymentNumber + 1;
END;